diff --git a/admin/background_jobs.pl b/admin/background_jobs.pl index a4b7b90c0a..761c09d069 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 ); @@ -78,15 +79,35 @@ if ( $op eq 'cancel' ) { if ( $op eq 'list' ) { - my $jobs = + my $queued_jobs = $can_manage_background_jobs - ? Koha::BackgroundJobs->search( {}, + ? Koha::BackgroundJobs->search( { ended_on => undef }, { order_by => { -desc => 'enqueued_on' } } ) : Koha::BackgroundJobs->search( - { borrowernumber => $logged_in_user->borrowernumber }, + { borrowernumber => $logged_in_user->borrowernumber, ended_on => undef }, { order_by => { -desc => 'enqueued_on' } } ); - $template->param( jobs => $jobs ); + $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 => { '>=' => $dtf->format_datetime($ended_since) } + }, + { order_by => { -desc => 'enqueued_on' } } + ) + : Koha::BackgroundJobs->search( + { + borrowernumber => $logged_in_user->borrowernumber, + ended_on => { '>=' => $dtf->format_datetime($ended_since) } + }, + { order_by => { -desc => 'enqueued_on' } } + ); + $template->param( complete => $complete_jobs ); } $template->param( 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 ab1cd65cba..0fafb30da4 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 @@ -156,49 +156,106 @@
| Job ID | -Status | -Progress | -Type | -Queued | -Started | -Ended | -Actions | -
|---|---|---|---|---|---|---|---|
| [% job.id | html %] | -- [% PROCESS show_job_status %] - | -[% job.progress || 0 | html %] / [% job.size | html %] | -- [% PROCESS show_job_type job_type => job.type %] - | -[% job.enqueued_on | $KohaDates with_hours = 1 %] | -[% job.started_on| $KohaDates with_hours = 1 %] | -[% job.ended_on| $KohaDates with_hours = 1 %] | -- View - [% IF job.status == 'new' || job.status == 'started' %] - Cancel - [% END %] - | -
| Job ID | +Status | +Progress | +Type | +Queued | +Started | +Actions | +
|---|---|---|---|---|---|---|
| [% job.id | html %] | ++ [% PROCESS show_job_status %] + | +[% job.progress || 0 | html %] / [% job.size | html %] | ++ [% PROCESS show_job_type job_type => job.type %] + | +[% job.enqueued_on | $KohaDates with_hours = 1 %] | +[% job.started_on| $KohaDates with_hours = 1 %] | ++ View + [% IF job.status == 'new' || job.status == 'started' %] + Cancel + [% END %] + | +
Jobs completed in the last 60 minutes.
+| Job ID | +Status | +Progress | +Type | +Queued | +Started | +Ended | +Actions | +
|---|---|---|---|---|---|---|---|
| [% job.id | html %] | ++ [% PROCESS show_job_status %] + | +[% job.progress || 0 | html %] / [% job.size | html %] | ++ [% PROCESS show_job_type job_type => job.type %] + | +[% job.enqueued_on | $KohaDates with_hours = 1 %] | +[% job.started_on| $KohaDates with_hours = 1 %] | +[% job.ended_on| $KohaDates with_hours = 1 %] | ++ View + [% IF job.status == 'new' || job.status == 'started' %] + Cancel + [% END %] + | +