[open-ils-commits] r18546 - branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application (miker)
svn at svn.open-ils.org
svn at svn.open-ils.org
Mon Nov 1 12:18:26 EDT 2010
Author: miker
Date: 2010-11-01 12:18:23 -0400 (Mon, 01 Nov 2010)
New Revision: 18546
Modified:
branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/SuperCat.pm
Log:
Include copy counts in holdings XML -- I will destroy MVRs yet!
Modified: branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/SuperCat.pm
===================================================================
--- branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/SuperCat.pm 2010-11-01 16:14:11 UTC (rev 18545)
+++ branches/rel_2_0/Open-ILS/src/perlmods/OpenILS/Application/SuperCat.pm 2010-11-01 16:18:23 UTC (rev 18546)
@@ -1709,6 +1709,7 @@
my $offset = $$paging[1] || 0;
my $_storage = OpenSRF::AppSession->create( 'open-ils.cstore' );
+ my $_search = OpenSRF::AppSession->create( 'open-ils.search' );
my $o_search = { shortname => uc($ou) };
if (!$ou || $ou eq '-') {
@@ -1720,6 +1721,16 @@
$o_search
)->gather(1);
+ my $top_org = defined($depth) ?
+ $_storage->request(
+ 'open-ils.cstore.json_query',
+ { from => [ 'actor.org_unit_ancestor_at_depth', $one_org->id, $depth ] }
+ )->gather(1)->{id} :
+ $one_org->id;
+
+ my $count_req = $_search->request('open-ils.search.biblio.record.copy_count.atomic' => $top_org => $bib);
+ my $staff_count_req = $_search->request('open-ils.search.biblio.record.copy_count.staff.atomic' => $top_org => $bib);
+
my $orgs = $_storage->request(
'open-ils.cstore.json_query.atomic',
{ from => [ 'actor.org_unit_descendants', defined($depth) ? ( $one_org->id, $depth ) : ( $one_org->id ) ] }
@@ -1780,7 +1791,26 @@
$year += 1900;
$month += 1;
- $client->respond("<holdings xmlns='http://open-ils.org/spec/holdings/v1'><volumes>\n");
+ $client->respond("<holdings xmlns='http://open-ils.org/spec/holdings/v1'><counts>\n")
+
+ my $copy_counts = $count_req->gather(1);
+ my $staff_copy_counts = $staff_count_req->gather(1);
+
+ for my $c (@$copy_counts) {
+ $$c{transcendant} ||= 0;
+ my $out = "<count type='public'";
+ $out .= " $_='$$c{$_}'" for (qw/count available unshadow transcendant org_unit depth/);
+ $client->respond("$out/>\n")
+ }
+
+ for my $c (@$staff_copy_counts) {
+ $$c{transcendant} ||= 0;
+ my $out = "<count type='staff'";
+ $out .= " $_='$$c{$_}'" for (qw/count available unshadow transcendant org_unit depth/);
+ $client->respond("$out/>\n")
+ }
+
+ $client->respond("</counts><volumes>\n");
for my $cn (@$cns) {
next unless (@{$cn->copies} > 0 or (ref($cn->uri_maps) and @{$cn->uri_maps}));
More information about the open-ils-commits
mailing list