From 215fe220cec3fa0ad4a20a5a0a91babb0d3e97ed Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Thu, 12 Oct 2023 14:10:51 +0000 Subject: [PATCH] Bug 35001: Take patron activity triggers into account in ->is_active Content-Type: text/plain; charset=utf-8 Still in concept. Test plan: TODO --- Koha/Patron.pm | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/Koha/Patron.pm b/Koha/Patron.pm index 5918e456af..f40febcefb 100644 --- a/Koha/Patron.pm +++ b/Koha/Patron.pm @@ -821,6 +821,9 @@ A recent enrollment as new patron counts too. Recently is defined by $date or $value in days, weeks or months. You should pass one of those; otherwise an exception is thrown. +The code takes the various triggers defined via pref TrackLastPatronActivityTriggers +into account when deciding the need for querying holds, issues, etc. + =cut sub is_active { @@ -847,33 +850,37 @@ sub is_active { return 1 if DateTime->compare( dt_from_string( $self->lastseen ), $dt ) > -1; } - # Check holds, issues and article requests - return 1 if $self->holds->filter_by_last_update( + # Check holds, issues and article requests (if not included in TrackLastPatronActivityTriggers) + # If included, the lastseen date has been updated, so no need to do the query + my $included = { map { ( $_, 1 ) } split /\s*,\s*/, lc C4::Context->preference('TrackLastPatronActivityTriggers') }; + return 1 if !$included->{hold} && $self->holds->filter_by_last_update( { timestamp_column_name => 'timestamp', from => $dt, } )->count; - return 1 if $self->old_holds->filter_by_last_update( + return 1 if !$included->{hold} && $self->old_holds->filter_by_last_update( { timestamp_column_name => 'timestamp', from => $dt, } )->count; - return 1 if $self->checkouts->filter_by_last_update( + return 1 if !$included->{check_out} && $self->checkouts->filter_by_last_update( { timestamp_column_name => 'timestamp', from => $dt, } )->count; - return 1 if $self->old_checkouts->filter_by_last_update( + return 1 if !$included->{check_out} && $self->old_checkouts->filter_by_last_update( { timestamp_column_name => 'timestamp', from => $dt, } )->count; - return 1 if $self->article_requests->filter_by_last_update( + return 1 if !$included->{article} && $self->article_requests->filter_by_last_update( { timestamp_column_name => 'updated_on', from => $dt, } )->count; + #TODO Currently, we have no way to add recalls at staff side for a patron. If added, extend this. + return 0; } -- 2.30.2