LP#1203734 copy circ counts include anon. circs rel_2_5_1
authorBill Erickson <berickxx@gmail.com>
Mon, 3 Nov 2014 22:55:00 +0000 (17:55 -0500)
committerChris Sharp <csharp@georgialibraries.org>
Mon, 10 Nov 2014 13:13:28 +0000 (08:13 -0500)
Circ counts displayed on "Show Last Few Circulations" (XUL) includes
active, anonymized, and legacy circulations (via cstore)

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Conflicts:

Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm

Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm
Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/asset.pm

index 76f1cb0..a378e58 100644 (file)
@@ -743,11 +743,27 @@ __PACKAGE__->register_method(
     /);
 
 sub circ_count {
-    my( $self, $client, $copyid, $range ) = @_; 
-    my $e = OpenILS::Utils::Editor->new;
-    return $e->request('open-ils.storage.asset.copy.circ_count', $copyid, $range);
-}
+    my( $self, $client, $copyid ) = @_; 
+
+    my $count = new_editor()->json_query({
+        select => {
+            circbyyr => [{
+                column => 'count',
+                transform => 'sum',
+                aggregate => 1
+            }]
+        },
+        from => 'circbyyr',
+        where => {'+circbyyr' => {copy => $copyid}}
+    })->[0]->{count};
 
+    return {
+        total => {
+            when => 'total',
+            count => $count
+        }
+    };
+}
 
 
 __PACKAGE__->register_method(
index 4dc3e47..435f104 100644 (file)
@@ -13,46 +13,6 @@ 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,