From 359007e0c6f5dac928872ddd5c9dc2fb8ef81300 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Fri, 10 Jun 2022 15:35:47 +0100 Subject: [PATCH] Bug 30462: (follow-up) Limit completed to 60 minutes This follow-up reduces the completed jobs list to only those jobs completed within the last 60 minutes. Signed-off-by: Jonathan Druart Signed-off-by: Kyle M Hall --- admin/background_jobs.pl | 19 +++++++++++++++---- .../prog/en/modules/admin/background_jobs.tt | 9 +++------ 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/admin/background_jobs.pl b/admin/background_jobs.pl index ae70985091..cccb3bba57 100755 --- a/admin/background_jobs.pl +++ b/admin/background_jobs.pl @@ -19,6 +19,7 @@ use Modern::Perl; use CGI qw ( -utf8 ); use C4::Context; +use Koha::DateUtils qw( dt_from_string ); use C4::Auth qw( get_template_and_user ); use C4::Output qw( output_html_with_http_headers ); @@ -88,13 +89,23 @@ if ( $op eq 'list' ) { ); $template->param( queued => $queued_jobs ); + my $ended_since = dt_from_string->subtract( minutes => '60' ); + my $dtf = Koha::Database->new->schema->storage->datetime_parser; + my $complete_jobs = $can_manage_background_jobs - ? Koha::BackgroundJobs->search( { ended_on => { '!=' => undef } }, - { order_by => { -desc => 'enqueued_on' } } ) + ? Koha::BackgroundJobs->search( + { + ended_on => { '>=' => $dtf->format_date($ended_since) } + }, + { order_by => { -desc => 'enqueued_on' } } + ) : Koha::BackgroundJobs->search( - { borrowernumber => $logged_in_user->borrowernumber, ended_on => { '!=' => undef } }, - { order_by => { -desc => 'enqueued_on' } } + { + borrowernumber => $logged_in_user->borrowernumber, + ended_on => { '>=' => $dtf->format_date($ended_since) } + }, + { order_by => { -desc => 'enqueued_on' } } ); $template->param( complete => $complete_jobs ); } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/background_jobs.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/background_jobs.tt index 1304fd57c4..7292dd2db0 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/background_jobs.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/background_jobs.tt @@ -164,8 +164,6 @@
-

Queued jobs

- [% IF queued.count %] @@ -211,10 +209,9 @@ [% END %] -
-

Complete jobs

- +
[% IF complete.count %] +

Jobs completed in the last 60 minutes.

@@ -254,7 +251,7 @@
[% ELSE %]
- There are no completed background jobs yet. + There were no completed background jobs completed in the last 60 minutes.
[% END %]
-- 2.30.2