}
);
+sub _flesh_and_emit_slots {
+ my ($conn, $e, $slots) = @_;
+
+ for my $s (@$slots) {
+ my $start_time;
+ my $end_time;
+ if ($s->delivered) {
+ $start_time = DateTime::Format::ISO8601->new->parse_datetime(clean_ISO8601($s->delivered));
+ $end_time = $start_time->clone->add(seconds => 90); # 90 seconds is arbitrary
+ }
+ my $holds = $e->search_action_hold_request([{
+ usr => $s->patron->id,
+ current_shelf_lib => $s->org,
+ pickup_lib => $s->org,
+ shelf_time => {'!=' => undef},
+ cancel_time => undef,
+ ($s->delivered) ?
+ (
+ '-and' => [ { fulfillment_time => {'>=' => $start_time->strftime('%FT%T%z') } },
+ { fulfillment_time => {'<=' => $end_time->strftime('%FT%T%z') } } ],
+ ) :
+ (fulfillment_time => undef),
+ },{
+ flesh => 1, flesh_fields => {ahr => ['current_copy']},
+ }]);
+
+ my $rhrr_list = $e->search_reporter_hold_request_record(
+ {id => [ map { $_->id } @$holds ]}
+ );
+
+ my %bib_data = map {
+ ($_->id => $e->retrieve_metabib_wide_display_entry( $_->bib_record))
+ } @$rhrr_list;
+
+ $conn->respond({slot_id => $s->id, slot => $s, holds => $holds, bib_data_by_hold => \%bib_data});
+ }
+}
+
sub fetch_delivered { # returns appointments delivered TODAY
my ($self, $conn, $authtoken, $org, $limit, $offset) = @_;
order_by => { acsp => {delivered => {direction => 'desc'}} }
}]);
- $conn->respond($_) for @$slots;
+ _flesh_and_emit_slots($conn, $e, $slots);
+
return undef;
}
__PACKAGE__->register_method(
order_by => { acsp => 'arrival' }
}]);
- for my $s (@$slots) {
- my $holds = $e->search_action_hold_request({
- usr => $s->patron->id,
- current_shelf_lib => $s->org,
- pickup_lib => $s->org,
- shelf_time => {'!=' => undef},
- cancel_time => undef,
- fulfillment_time => undef
- });
- $conn->respond({slot_id => $s->id, slot => $s, holds => $holds});
- }
+ _flesh_and_emit_slots($conn, $e, $slots);
return undef;
}
order_by => { acsp => 'slot' }
}]);
- for my $s (@$slots) {
- my $holds = $e->search_action_hold_request({
- usr => $s->patron->id,
- current_shelf_lib => $s->org,
- pickup_lib => $s->org,
- shelf_time => {'!=' => undef},
- cancel_time => undef,
- fulfillment_time => undef
- });
-
- $conn->respond({slot_id => $s->id, slot => $s, holds => $holds});
- }
+ _flesh_and_emit_slots($conn, $e, $slots);
return undef;
}
order_by => { acsp => 'slot' }
}]);
- for my $s (@$slots) {
- my $holds = $e->search_action_hold_request([{
- usr => $s->patron->id,
- current_shelf_lib => $s->org,
- pickup_lib => $s->org,
- shelf_time => {'!=' => undef},
- cancel_time => undef,
- fulfillment_time => undef
- },{
- flesh => 1, flesh_fields => {ahr => ['current_copy']},
- }]);
-
- my $rhrr_list = $e->search_reporter_hold_request_record(
- {id => [ map { $_->id } @$holds ]}
- );
-
- my %bib_data = map {
- ($_->id => $e->retrieve_metabib_wide_display_entry( $_->bib_record))
- } @$rhrr_list;
-
- $conn->respond({slot_id => $s->id, slot => $s, holds => $holds, bib_data_by_hold => \%bib_data});
- }
+ _flesh_and_emit_slots($conn, $e, $slots);
return undef;
}