From a939f8da154cd6e28a8edabe2aba709f082d74c4 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Thu, 12 Oct 2023 07:35:58 +0000 Subject: [PATCH] Bug 15504: (QA follow-up) Final changes [1] Comment in Patron->is_active sharpened. [2] Patron->update_lastseen return if $cached && $cached eq $now->ymd; Should be return $self if $cached && $cached eq $now->ymd; Consistent return value. [3] Typo if there are not TrackLastPatronActivityTriggers enabled [4] Typo TrackLastPatronActivityTriggers must be contain [5] Typo patron is does .. option => performs an action [6] Tidy on dbrev to fix The file is less tidy than before (bad/messy lines before: 0, now: 4) Signed-off-by: Marcel de Rooy Signed-off-by: Tomas Cohen Arazi --- Koha/Patron.pm | 4 ++-- ...bug_15504-add-tracklastpatronactivityoptions.pl | 14 +++++++++----- installer/data/mysql/mandatory/sysprefs.sql | 2 +- misc/cronjobs/delete_patrons.pl | 4 ++-- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/Koha/Patron.pm b/Koha/Patron.pm index ac87e66674..5918e456af 100644 --- a/Koha/Patron.pm +++ b/Koha/Patron.pm @@ -842,7 +842,7 @@ sub is_active { # Enrollment within this period? return 1 if DateTime->compare( dt_from_string( $self->dateenrolled ), $dt ) > -1; - # Last seen? Updated each login when you track patron activity + # Last seen? Updated for tracked patron activities if ( C4::Context->preference('TrackLastPatronActivityTriggers') ) { return 1 if DateTime->compare( dt_from_string( $self->lastseen ), $dt ) > -1; } @@ -1189,7 +1189,7 @@ sub update_lastseen { my $cache_key = "track_activity_" . $self->borrowernumber; my $cached = $cache->get_from_cache($cache_key); my $now = dt_from_string(); - return if $cached && $cached eq $now->ymd; + return $self if $cached && $cached eq $now->ymd; $self->lastseen($now)->store; $cache->set_in_cache( $cache_key, $now->ymd ); diff --git a/installer/data/mysql/atomicupdate/bug_15504-add-tracklastpatronactivityoptions.pl b/installer/data/mysql/atomicupdate/bug_15504-add-tracklastpatronactivityoptions.pl index 4064a2ed11..fa2b8d22d3 100755 --- a/installer/data/mysql/atomicupdate/bug_15504-add-tracklastpatronactivityoptions.pl +++ b/installer/data/mysql/atomicupdate/bug_15504-add-tracklastpatronactivityoptions.pl @@ -8,21 +8,25 @@ return { my ( $dbh, $out ) = @$args{qw(dbh out)}; # Get existing value from the TrackLastPatronActivity system preference - my ($tracklastactivity) = $dbh->selectrow_array( q| + my ($tracklastactivity) = $dbh->selectrow_array( + q| SELECT value FROM systempreferences WHERE variable='TrackLastPatronActivity'; - |); + | + ); my $triggers = $tracklastactivity ? 'check_out,connection,login' : ''; $dbh->do( - qq{INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('TrackLastPatronActivityTriggers',?,NULL,'If set, the field borrowers.lastseen will be updated every time a patron is does a selected option','multiple') }, + qq{INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('TrackLastPatronActivityTriggers',?,NULL,'If set, the field borrowers.lastseen will be updated every time a patron performs a selected action','multiple') }, undef, $triggers, ); say $out "Added system preference 'TrackLastPatronActivityTriggers'"; - $dbh->do(q{ + $dbh->do( + q{ DELETE FROM systempreferences WHERE variable='TrackLastPatronActivity' - }); + } + ); say $out "Removed system preference 'TrackLastPatronActivity'"; }, diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index 19ae5a901a..6af4e7b210 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -753,7 +753,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('TraceCompleteSubfields','0','0','Force subject tracings to only match complete subfields.','YesNo'), ('TraceSubjectSubdivisions','0','1','Create searches on all subdivisions for subject tracings.','YesNo'), ('TrackClicks','0',NULL,'Track links clicked','Integer'), -('TrackLastPatronActivityTriggers','',NULL,'If set, the field borrowers.lastseen will be updated everytime a patron is does a selected option','multiple'), +('TrackLastPatronActivityTriggers','',NULL,'If set, the field borrowers.lastseen will be updated everytime a patron performs a selected action','multiple'), ('TransfersBlockCirc','1',NULL,'Should the transfer modal block circulation staff from continuing scanning items','YesNo'), ('TransfersMaxDaysWarning','3',NULL,'Define the days before a transfer is suspected of having a problem','Integer'), ('TransferWhenCancelAllWaitingHolds','0',NULL,'Transfer items when cancelling all waiting holds','YesNo'), diff --git a/misc/cronjobs/delete_patrons.pl b/misc/cronjobs/delete_patrons.pl index b9e54f8328..7962233efa 100755 --- a/misc/cronjobs/delete_patrons.pl +++ b/misc/cronjobs/delete_patrons.pl @@ -39,7 +39,7 @@ $expired_before = dt_from_string( $expired_before, 'iso' ) if $expired_before; if ( $last_seen and not C4::Context->preference('TrackLastPatronActivityTriggers') ) { - pod2usage(q{The --last_seen will be ineffective if there are not TrackLastPatronActivityTriggers enabled}); + pod2usage(q{The option --last_seen will be ineffective if preference TrackLastPatronActivityTriggers is empty}); } unless ( $not_borrowed_since or $expired_before or $last_seen or @category_code or $branchcode or $file ) { @@ -185,7 +185,7 @@ Delete patrons with an account expired before this date. Delete patrons who have not been active since this date. -The system preference TrackLastPatronActivityTriggers must be contain least trigger to use this option. +The system preference TrackLastPatronActivityTriggers must contain at least one trigger to use this option. =item B<--category_code> -- 2.39.5