$self->mk_copy_query($rec_id, $org, $copy_depth, $copy_limit, $copy_offset, $pref_ou)
);
+ if ($self->cgi->param('badges')) {
+ my $badges = $self->cgi->param('badges');
+ $badges = $badges ? split(',', $badges) : [];
+ $badges = [grep { /^\d+$/ } @$badges]
+ if (@$badges) {
+ $self->ctx->{badge_scores} = $cstore->request(
+ 'open-ils.cstore.direct.rating.record_badge_score.search.atomic',
+ { record => $rec_id, badge => $badges }
+ )->gather(1);
+ }
+ } else {
+ $self->ctx->{badge_scores} = [];
+ }
+
# find foreign copy data
my $peer_rec = $U->simplereq(
'open-ils.search',
$ctx->{copy_location_groups} = \%buckets;
}
+my $badge_cache_age = 100;
+my $badge_cache = undef;
+sub load_badges {
+ my $self = shift;
+ my $ctx = $self->ctx;
+
+ # Grab badges every 100 page loads in this apache backend
+ if ($badge_cache && --$badge_cache_age) {
+ return $ctx->{all_badges} = $badge_cache;
+ }
+
+ $badge_cache_age = 100;
+
+ my $badges = $self->editor->search_rating_badge(
+ { id => { '!=' => undef } }
+ ]);
+
+ if (@$badges) {
+ my %badge_hash = map {($_->id => $_)} @$badges;
+ return $ctx->{all_badges} = $badge_cache = \%badge_hash;
+ }
+
+ return;
+}
+
sub set_file_download_headers {
my $self = shift;
my $filename = shift;