LP#1410369: update TPAC dashboard counts as needed
authorGalen Charlton <gmc@esilibrary.com>
Wed, 18 Feb 2015 22:17:46 +0000 (22:17 +0000)
committerBill Erickson <berickxx@gmail.com>
Fri, 20 Feb 2015 21:58:17 +0000 (16:58 -0500)
This factors the lookup of TPAC dashboard/"vital" stats
to a separate routine and invokes it a couple more times
as needed during patron message processing that can
affect the count of unread messages.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Kathy Lussier <klussier@masslnc.org>
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm

index afcd8a9..4147b8f 100644 (file)
@@ -298,10 +298,7 @@ sub load_common {
                 $ctx->{is_browser_staff} = 1;
             }
 
-            $ctx->{user_stats} = $U->simplereq(
-                'open-ils.actor', 
-                'open-ils.actor.user.opac.vital_stats', 
-                $e->authtoken, $e->requestor->id);
+            $self->update_dashboard_stats();
 
         } else {
 
@@ -325,6 +322,18 @@ sub load_common {
     return Apache2::Const::OK;
 }
 
+sub update_dashboard_stats {
+    my $self = shift;
+
+    my $e = $self->editor;
+    my $ctx = $self->ctx;
+
+    $ctx->{user_stats} = $U->simplereq(
+        'open-ils.actor', 
+        'open-ils.actor.user.opac.vital_stats', 
+        $e->authtoken, $e->requestor->id);
+}
+
 sub staff_saved_searches_set_expansion_state {
     my $self = shift;
 
index 514bc61..5267599 100644 (file)
@@ -283,6 +283,7 @@ sub load_myopac_messages {
             $ctx->{message_update_action} = $action;
             $ctx->{message_update_changed} = $changed;
             $ctx->{message_update_failed} = $failed;
+            $self->update_dashboard_stats();
         }
     }
 
@@ -355,6 +356,8 @@ sub _fetch_and_mark_read_single_message {
     }
     $pcrud->request('open-ils.pcrud.transaction.commit', $self->editor->authtoken)->gather(1);
 
+    $self->update_dashboard_stats();
+
     return $messages;
 }