From 330641d41062603b65f370b5138b7e0a5d7d04e8 Mon Sep 17 00:00:00 2001 From: Andrew Isherwood Date: Tue, 19 Feb 2019 11:36:49 +0000 Subject: [PATCH] Bug 20750: (follow-up) Use Koha::ActionLogs We now use Koha::ActionLogs in favour of C4::Log::GetLogs. This enables us to deprecate Koha::Illrequest::Logger::get_epoch This adds a dependency on Bug 22363. --- Koha/Illrequest/Logger.pm | 46 +++++++++++----------------------------------- 1 file changed, 11 insertions(+), 35 deletions(-) diff --git a/Koha/Illrequest/Logger.pm b/Koha/Illrequest/Logger.pm index e855e39309..da4f65947b 100644 --- a/Koha/Illrequest/Logger.pm +++ b/Koha/Illrequest/Logger.pm @@ -24,7 +24,8 @@ use Time::Local; use C4::Koha; use C4::Context; use C4::Templates; -use C4::Log qw( logaction GetLogs ); +use C4::Log qw( logaction ); +use Koha::ActionLogs; =head1 NAME @@ -198,26 +199,6 @@ sub get_log_template { } } -=head3 get_epoch - - $epoch = Koha::Illrequest::Logger->get_epoch($timestamp); - -Given a timestamp string returned from GetLogs, get the epoch - -=cut - -sub get_epoch { - my $timestamp = shift; - - return if !$timestamp=~/\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}/; - - my ($date, $time) = split(/\s/, $timestamp); - my ($y, $mon, $d) = split(/-/, $date); - my ($h, $min, $s) = split(/:/, $time); - - return timelocal($s, $min, $h, $d, $mon-1, $y); -} - =head3 get_request_logs $requestlogs = Koha::IllRequest::Logger->get_request_logs($request_id); @@ -229,16 +210,14 @@ Get all logged actions for a given request sub get_request_logs { my ( $self, $request ) = @_; - my $logs = GetLogs( - undef, - undef, - undef, - ['ILL'], - undef, - $request->id, - undef, - undef - ); + my $logs = Koha::ActionLogs->search( + { + module => 'ILL', + object => $request->id + }, + { order_by => { -desc => "timestamp" } } + )->unblessed; + # Populate a lookup table for status aliases my $aliases = GetAuthorisedValues('ILLSTATUS'); my $alias_hash; @@ -257,10 +236,7 @@ sub get_request_logs { ); } - my $format = '%Y-%m-%d %H:%M:%S'; - my @sorted = sort { get_epoch($$b{'timestamp'}) <=> get_epoch($$a{'timestamp'}) } @{$logs}; - - return \@sorted; + return $logs; } =head1 AUTHOR -- 2.11.0