add error and item import/error summary info to queue summary api call
authorberick <berick@esilibrary.com>
Mon, 25 Apr 2011 20:33:48 +0000 (16:33 -0400)
committerBill Erickson <berick@esilibrary.com>
Wed, 6 Jul 2011 18:50:51 +0000 (14:50 -0400)
Open-ILS/src/perlmods/lib/OpenILS/Application/Vandelay.pm

index b431422..7f34422 100644 (file)
@@ -1128,11 +1128,41 @@ sub retrieve_queue_summary {
     my $search = 'search_vandelay_queued_bib_record';
     $search =~ s/bib/authority/ if $type ne 'bib';
 
-    return {
+    my $summary = {
         queue => $queue,
         total => scalar(@{$e->$search({queue => $queue_id}, {idlist=>1})}),
         imported => scalar(@{$e->$search({queue => $queue_id, import_time => {'!=' => undef}}, {idlist=>1})}),
     };
+
+    my $class = ($type eq 'bib') ? 'vqbr' : 'vqar';
+    $summary->{rec_import_errors} = $e->json_query({
+        select => {$class => [{alias => 'count', column => 'id', transform => 'count', aggregate => 1}]},
+        from => $class,
+        where => {queue => $queue_id, import_error => {'!=' => undef}}
+    })->[0]->{count};
+
+    if($type eq 'bib') {
+        
+        my $query = {
+            select => {vii => [{alias => 'count', column => 'id', transform => 'count', aggregate => 1}]},
+            from => 'vii',
+            where => {
+                record => {
+                    in => {
+                        select => {vqbr => ['id']},
+                        from => 'vqbr',
+                        where => {queue => $queue_id}
+                    }
+                }
+            }
+        };
+
+        $summary->{total_items} = $e->json_query($query)->[0]->{count};
+        $query->{where}->{import_error} = {'!=' => undef};
+        $summary->{item_import_errors} = $e->json_query($query)->[0]->{count};
+    }
+
+    return $summary;
 }
 
 # --------------------------------------------------------------------------------