From: Bill Erickson Date: Mon, 6 Feb 2012 17:31:23 +0000 (-0500) Subject: User activity tracking : user usr_activity field X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=f046fa0a17dc74916c62a255f8d08d7e9f3314af;p=evergreen%2Fequinox.git User activity tracking : user usr_activity field Added a new virtual field to actor.usr called "usr_activity". When fleshed, the value contains the most recent activities logged for the user. By default, only the most recent activity entry is fetched, however this commit also adds an org unit setting "circ.patron.usr_activity_retrieve.max" to control the number of entries returned for standard patron fleshing calls. Activity entries are fleshed in the calls: open-ils.actor.user.fleshed.retrieve open-ils.actor.user.fleshed.retrieve_by_barcode This change also updates the permacrud permission for usr_activity form VIEW_USER to RUN_REPORTS, with the assumption that any activity data beyond the configured amount (above) should be considered historical data that is not as readily accessable. Signed-off-by: Bill Erickson Signed-off-by: Thomas Berezansky --- diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml index 237c8c227a..2924bfca5c 100644 --- a/Open-ILS/examples/fm_IDL.xml +++ b/Open-ILS/examples/fm_IDL.xml @@ -2703,6 +2703,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + @@ -2734,6 +2735,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + @@ -2769,7 +2771,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA - + diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm index 60118d34e3..627ee87bcc 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm @@ -2955,7 +2955,8 @@ sub user_retrieve_fleshed_by_id { "addresses", "billing_address", "mailing_address", - "stat_cat_entries" ]; + "stat_cat_entries", + "usr_activity" ]; return new_flesh_user($user_id, $fields, $e); } @@ -2972,6 +2973,12 @@ sub new_flesh_user { $fetch_penalties = 1; } + my $fetch_usr_act = 0; + if(grep {$_ eq 'usr_activity'} @$fields) { + $fields = [grep {$_ ne 'usr_activity'} @$fields]; + $fetch_usr_act = 1; + } + my $user = $e->retrieve_actor_user( [ $id, @@ -3020,6 +3027,31 @@ sub new_flesh_user { ); } + # retrieve the most recent usr_activity entry + if ($fetch_usr_act) { + + # max number to return for simple patron fleshing + my $limit = $U->ou_ancestor_setting_value( + $e->requestor->ws_ou, + 'circ.patron.usr_activity_retrieve.max'); + + my $opts = { + flesh => 1, + flesh_fields => {auact => ['etype']}, + order_by => {auact => 'event_time DESC'}, + }; + + # 0 == none, <0 == return all + $limit = 1 unless defined $limit; + $opts->{limit} = $limit if $limit > 0; + + $user->usr_activity( + ($limit == 0) ? + [] : # skip the DB call + $e->search_actor_usr_activity([{usr => $user->id}, $opts]) + ); + } + $e->rollback; $user->clear_passwd(); return $user; diff --git a/Open-ILS/src/sql/Pg/950.data.seed-values.sql b/Open-ILS/src/sql/Pg/950.data.seed-values.sql index 2ca7c7bb64..94e7626f84 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -11352,3 +11352,23 @@ INSERT INTO config.usr_activity_type (id, ewho, ewhat, ehow, egroup, label) VALU -- reserve the first 1000 slots SELECT SETVAL('config.usr_activity_type_id_seq'::TEXT, 1000); +INSERT INTO config.org_unit_setting_type + (name, label, description, grp, datatype) + VALUES ( + 'circ.patron.usr_activity_retrieve.max', + oils_i18n_gettext( + 'circ.patron.usr_activity_retrieve.max', + 'Max user activity entries to retrieve (staff client)', + 'coust', + 'label' + ), + oils_i18n_gettext( + 'circ.patron.usr_activity_retrieve.max', + 'Sets the maxinum number of recent user activity entries to retrieve for display in the staff client. 0 means show none, -1 means show all. Default is 1.', + 'coust', + 'description' + ), + 'gui', + 'integer' + ); + diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.user-activity.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.user-activity.sql index 30b33960a5..de8cc5eb7d 100644 --- a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.user-activity.sql +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.user-activity.sql @@ -126,6 +126,27 @@ INSERT INTO config.usr_activity_type (id, ewho, ewhat, ehow, egroup, label) VALU -- reserve the first 1000 slots SELECT SETVAL('config.usr_activity_type_id_seq'::TEXT, 1000); +INSERT INTO config.org_unit_setting_type + (name, label, description, grp, datatype) + VALUES ( + 'circ.patron.usr_activity_retrieve.max', + oils_i18n_gettext( + 'circ.patron.usr_activity_retrieve.max', + 'Max user activity entries to retrieve (staff client)', + 'coust', + 'label' + ), + oils_i18n_gettext( + 'circ.patron.usr_activity_retrieve.max', + 'Sets the maxinum number of recent user activity entries to retrieve for display in the staff client. 0 means show none, -1 means show all. Default is 1.', + 'coust', + 'description' + ), + 'gui', + 'integer' + ); + + COMMIT; /*