From 9c03ba417857f7b956b1965d98b98f9036999711 Mon Sep 17 00:00:00 2001 From: Chris Sharp Date: Mon, 10 Nov 2014 08:04:13 -0500 Subject: [PATCH] Revert "Fixing LP#1203734 - "Show Last Few Circulations" interface not counting archived circulations." This reverts commit 4978ead0608a0c45a7e0f0c77380d0548a80e1e1. Conflicts: Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/asset.pm --- .../OpenILS/Application/Storage/Publisher/asset.pm | 40 ++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/asset.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/asset.pm index f5e3279a3b..f95338fb75 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/asset.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/asset.pm @@ -13,6 +13,46 @@ my $log = 'OpenSRF::Utils::Logger'; use MARC::Record; use MARC::File::XML ( BinaryEncoding => 'UTF-8' ); +sub circ_count { + my $self = shift; + my $client = shift; + my $copy = shift; + my $granularity = shift; + + my $c_table = action::circulation->table; + + if (lc($granularity) eq 'year') { + $granularity = ", to_char(xact_start, 'YYYY') as when"; + } elsif (lc($granularity) eq 'month') { + $granularity = ", to_char(xact_start, 'YYYY-MM') as when"; + } elsif (lc($granularity) eq 'day') { + $granularity = ", to_char(xact_start, 'YYYY-MM-DD') as when"; + } else { + $granularity = ", 'total' as when"; + } + + my $SQL = <<" SQL"; + SELECT COUNT(*) as count $granularity + FROM $c_table + WHERE target_copy = ? + SQL + + + if ($granularity !~ /total/o) { + $SQL .= ' GROUP BY 2 ORDER BY 2'; + } + + $log->debug("Circ count SQL [$SQL]", DEBUG); + + return action::circulation->db_Main->selectall_hashref($SQL, 'when', {}, $copy); +} +__PACKAGE__->register_method( + method => 'circ_count', + api_name => 'open-ils.storage.asset.copy.circ_count', + argc => 1, +); + + #our $_default_subfield_map = { # call_number => $cn, # barcode => $bc, -- 2.11.0