Bugzilla – Attachment 107398 Details for
Bug 22417
Add a task queue
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 22417: Try to display pending jobs - only work if worker not started
Bug-22417-Try-to-display-pending-jobs---only-work-.patch (text/plain), 3.11 KB, created by
Jonathan Druart
on 2020-07-27 07:55:13 UTC
(
hide
)
Description:
Bug 22417: Try to display pending jobs - only work if worker not started
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2020-07-27 07:55:13 UTC
Size:
3.11 KB
patch
obsolete
>From 4b2fa5e118d75d78033803237f06cfdd8272c30a Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 20 Feb 2020 13:26:53 +0100 >Subject: [PATCH] Bug 22417: Try to display pending jobs - only work if worker > not started > >ie. no subscription yet > >This needs to be fixed (if possible), or removed from the patchset > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > admin/background_jobs.pl | 27 ++++++++++++++++++- > .../prog/en/modules/admin/background_jobs.tt | 13 ++++++++- > 2 files changed, 38 insertions(+), 2 deletions(-) > >diff --git a/admin/background_jobs.pl b/admin/background_jobs.pl >index 498891c80a..4eacc8c4d4 100755 >--- a/admin/background_jobs.pl >+++ b/admin/background_jobs.pl >@@ -18,6 +18,8 @@ > use Modern::Perl; > use CGI qw ( -utf8 ); > use JSON qw( decode_json ); >+use Try::Tiny; >+ > use C4::Context; > use C4::Auth; > use C4::Output; >@@ -64,7 +66,30 @@ if ( $op eq 'cancel' ) { > > if ( $op eq 'list' ) { > my $jobs = Koha::BackgroundJobs->search({}, { order_by => { -desc => 'enqueued_on' }}); >- $template->param( jobs => $jobs, ); >+ my @pending_jobs; >+ try { >+ my $conn = Koha::BackgroundJob->connect; >+ my $job_type = 'batch_biblio_record_modification'; >+ $conn->subscribe({ destination => $job_type, ack => 'client' }); >+ my @frames; >+ while (my $frame = $conn->receive_frame({timeout => 1})) { >+ last unless $frame; >+ my $body = $frame->body; >+ my $args = decode_json($body); >+ push @pending_jobs, $args->{job_id}; >+ push @frames, $frame; >+ } >+ $conn->nack( { frame => $_ } ) for @frames; >+ $conn->disconnect; >+ } catch { >+ push @messages, { >+ type => 'error', >+ code => 'cannot_retrieve_jobs', >+ error => $_, >+ }; >+ }; >+ >+ $template->param( jobs => $jobs, pending_jobs => \@pending_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 d1cc6cec7d..2b04c0a844 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 >@@ -21,8 +21,10 @@ > <main> > > [% FOR m IN messages %] >- <div class="dialog [% m.type | html %]"> >+ <div class="dialog message"> > [% SWITCH m.code %] >+ [% CASE 'cannot_retrieve_jobs' %] >+ <div><i class="fa fa-exclamation error"></i>Cannot retrieve pending jobs ([% m.error %])</div> > [% CASE %] > [% m.code | html %] > [% END %] >@@ -109,6 +111,15 @@ > > <h2>Background jobs</h2> > >+ <div class="dialog message"> >+ <i class="fa fa-info"></i> >+ [% IF pending_jobs.size > 0 %] >+ There is [% pending_jobs.size %] pending jobs on the server: [% pending_jobs.join(', ') %]. >+ [% ELSE %] >+ There is no pending jobs on the server. >+ [% END %] >+ </div> >+ > [% IF jobs.count %] > <table id="table_background_jobs"> > <thead> >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 22417
:
105542
|
105543
|
107385
|
107386
|
107387
|
107388
|
107389
|
107390
|
107391
|
107392
|
107393
|
107394
|
107395
|
107396
|
107397
|
107398
|
107399
|
107400
|
107401
|
107402
|
107403
|
107404
|
107405
|
107406
|
107481
|
107482
|
107682
|
108023
|
108024
|
108025
|
108026
|
108027
|
108028
|
108029
|
108030
|
108031
|
108032
|
108033
|
108034
|
108035
|
108036
|
108037
|
108038
|
108039
|
108040
|
108041
|
108042
|
108043
|
108044
|
108045
|
108046
|
108047
|
109270
|
109271
|
109319
|
109320
|
109321
|
109322
|
109323
|
109324
|
109325
|
109326
|
109327
|
109328
|
109329
|
109330
|
109331
|
109332
|
109333
|
109334
|
109335
|
109336
|
109337
|
109338
|
109339
|
109340
|
109341
|
109342
|
109343
|
109344
|
109345
|
109350
|
109351
|
109355
|
109390
|
109391
|
109392
|
109393
|
109394
|
109395
|
109396
|
109397
|
109398
|
109399
|
109400
|
109401
|
109402
|
109403
|
109404
|
109405
|
109406
|
109407
|
109408
|
109409
|
109410
|
109411
|
109412
|
109413
|
109414
|
109415
|
109416
|
109417
|
109418
|
109474
|
109475
|
109476
|
109477
|
110150
|
111091
|
111092
|
111093
|
111094
|
111095
|
111096
|
111097
|
111098
|
111099
|
111100
|
111101
|
111102
|
111103
|
111104
|
111105
|
111106
|
111107
|
111108
|
111109
|
111110
|
111111
|
111112
|
111113
|
111114
|
111115
|
111116
|
111117
|
111118
|
111119
|
111120
|
111121
|
111238
|
111239
|
111245