Bug 15504: Update track_login_daily to accept triggers

This patch adds triggers to track_login_daily so that it only tracks activity when that trigger is active

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Matt Blenkinsop 2023-06-14 14:11:08 +00:00 committed by Tomas Cohen Arazi
parent b694c85edf
commit 6b20144bbb
No known key found for this signature in database
GPG Key ID: 0A272EA1B2F3C15F
1 changed files with 6 additions and 1 deletions

View File

@ -2358,7 +2358,8 @@ Wraps the call to $patron->track_login, the method used to update borrowers.last
sub track_login_daily {
my $userid = shift;
return if !$userid || !C4::Context->preference('TrackLastPatronActivity');
my $activity = shift;
return if !$userid || !$activity || !C4::Context->preference('TrackLastPatronActivity');
my $cache = Koha::Caches->get_instance();
my $cache_key = "track_login_" . $userid;
@ -2368,6 +2369,10 @@ sub track_login_daily {
my $patron = Koha::Patrons->find({ userid => $userid });
return unless $patron;
my $tracked_activities = { map { (lc $_, 1); } split /\s*\,\s*/, C4::Context->preference('TrackLastPatronActivityTriggers') };
return unless $tracked_activities->{$activity};
$patron->track_login;
$cache->set_in_cache( $cache_key, $today );
}