[open-ils-commits] r14746 - trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher (miker)

svn at svn.open-ils.org svn at svn.open-ils.org
Tue Nov 3 13:54:45 EST 2009


Author: miker
Date: 2009-11-03 13:54:41 -0500 (Tue, 03 Nov 2009)
New Revision: 14746

Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm
Log:
adding count variants of the pull list and status-filtered pull list methods

Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm	2009-11-03 18:50:40 UTC (rev 14745)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm	2009-11-03 18:54:41 UTC (rev 14746)
@@ -411,6 +411,7 @@
 	my $ord_table = asset::copy_location_order->table;
 
 	my $idlist = 1 if ($self->api_name =~/id_list/o);
+	my $count = 1 if ($self->api_name =~/count$/o);
 
 	my $status_filter = '';
 	$status_filter = 'AND a.status IN (0,7)' if ($self->api_name =~/status_filtered/o);
@@ -430,10 +431,25 @@
 		  OFFSET $offset
 	SQL
 
+    if ($count) {
+        $select = <<"        SQL";
+            SELECT    count(*)
+              FROM    $h_table h
+                  JOIN $a_table a ON (h.current_copy = a.id)
+              WHERE    a.circ_lib = ?
+                  AND h.capture_time IS NULL
+                  AND h.cancel_time IS NULL
+                  AND (h.expire_time IS NULL OR h.expire_time > NOW())
+                $status_filter
+        SQL
+    }
+
 	my $sth = action::survey->db_Main->prepare_cached($select);
 	$sth->execute($ou);
 
-	if ($idlist) {
+	if ($count) {
+		$client->respond( $sth->fetchall_arrayref()->[0][0] );
+	} elsif ($idlist) {
 		$client->respond( $_->{id} ) for ( $sth->fetchall_hash );
 	} else {
 		$client->respond( $_->to_fieldmapper ) for ( map { action::hold_request->construct($_) } $sth->fetchall_hash );
@@ -442,6 +458,28 @@
 	return undef;
 }
 __PACKAGE__->register_method(
+	api_name        => 'open-ils.storage.direct.action.hold_request.pull_list.current_copy_circ_lib.count',
+	api_level       => 1,
+	stream          => 1,
+	signature	=> [
+		"Returns a count of holds for a specific library's pull list.",
+ 		[ [org_unit => "The library's org id", "number"] ],
+		['A count of holds for the stated library to pull ', 'number']
+	],
+	method          => 'hold_pull_list',
+);
+__PACKAGE__->register_method(
+	api_name        => 'open-ils.storage.direct.action.hold_request.pull_list.current_copy_circ_lib.status_filtered.count',
+	api_level       => 1,
+	stream          => 1,
+	signature	=> [
+		"Returns a status filtered count of holds for a specific library's pull list.",
+ 		[ [org_unit => "The library's org id", "number"] ],
+		['A status filtered count of holds for the stated library to pull ', 'number']
+	],
+	method          => 'hold_pull_list',
+);
+__PACKAGE__->register_method(
 	api_name        => 'open-ils.storage.direct.action.hold_request.pull_list.id_list.current_copy_circ_lib',
 	api_level       => 1,
 	stream          => 1,



More information about the open-ils-commits mailing list