[open-ils-commits] r11120 - trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ
svn at svn.open-ils.org
svn at svn.open-ils.org
Mon Nov 10 16:35:44 EST 2008
Author: erickson
Date: 2008-11-10 16:35:36 -0500 (Mon, 10 Nov 2008)
New Revision: 11120
Modified:
trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm
Log:
added method to return basic hold queue information
Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm 2008-11-10 19:40:31 UTC (rev 11119)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm 2008-11-10 21:35:36 UTC (rev 11120)
@@ -654,12 +654,60 @@
}
-#sub find_local_hold {
-# my( $class, $session, $copy, $user ) = @_;
-# return $class->find_nearest_permitted_hold($session, $copy, $user);
-#}
+__PACKAGE__->register_method(
+ method => "retrieve_hold_queue_stats",
+ api_name => "open-ils.circ.hold.queue_stats.retrieve",
+ signature => {
+ desc => q/
+ Returns object with total_holds count, queue_position, and potential_copies count
+ /
+ }
+);
+sub retrieve_hold_queue_stats {
+ my($self, $conn, $auth, $hold_id) = @_;
+ my $e = new_editor(authtoken => $auth);
+ return $e->event unless $e->checkauth;
+ my $hold = $e->retrieve_action_hold_request($hold_id) or return $e->event;
+ if($e->requestor->id != $hold->usr) {
+ return $e->event unless $e->allowed('VIEW_HOLD');
+ }
+ return retrieve_hold_queue_status_impl($e, $hold);
+}
+
+sub retrieve_hold_queue_status_impl {
+ my $e = shift;
+ my $hold = shift;
+
+ my $hold_ids = $e->search_action_hold_request(
+ [
+ { target => $hold->target,
+ hold_type => $hold->hold_type,
+ cancel_time => undef,
+ fulfillment_time => undef
+ },
+ {order_by => {ahr => 'request_time asc'}}
+ ],
+ {idlist => 1}
+ );
+
+ my $pos = 0;
+ for my $hid (@$hold_ids) {
+ $pos++;
+ last if $hid == $hold->id;
+ }
+
+ my $potentials = $e->search_action_hold_copy_map({hold => $hold->id}, {idlist => 1});
+
+ return {
+ total_holds => scalar(@$hold_ids),
+ queue_position => $pos,
+ potential_copies => scalar(@$potentials)
+ };
+}
+
+
sub fetch_open_hold_by_current_copy {
my $class = shift;
my $copyid = shift;
More information about the open-ils-commits
mailing list