From df60b861a629cdb59dd4ea3abbe83c99a13869d7 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. --- 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 326e8d596c..6cbc060621 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 ); @@ -86,13 +87,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 a98f06ef7f..cea9bef053 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.20.1