|
Lines 18-23
Link Here
|
| 18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
| 19 |
use CGI qw ( -utf8 ); |
19 |
use CGI qw ( -utf8 ); |
| 20 |
use JSON qw( decode_json ); |
20 |
use JSON qw( decode_json ); |
|
|
21 |
use Try::Tiny; |
| 22 |
|
| 21 |
use C4::Context; |
23 |
use C4::Context; |
| 22 |
use C4::Auth; |
24 |
use C4::Auth; |
| 23 |
use C4::Output; |
25 |
use C4::Output; |
|
Lines 64-70
if ( $op eq 'cancel' ) {
Link Here
|
| 64 |
|
66 |
|
| 65 |
if ( $op eq 'list' ) { |
67 |
if ( $op eq 'list' ) { |
| 66 |
my $jobs = Koha::BackgroundJobs->search({}, { order_by => { -desc => 'enqueued_on' }}); |
68 |
my $jobs = Koha::BackgroundJobs->search({}, { order_by => { -desc => 'enqueued_on' }}); |
| 67 |
$template->param( jobs => $jobs, ); |
69 |
my @pending_jobs; |
|
|
70 |
try { |
| 71 |
my $conn = Koha::BackgroundJob->connect; |
| 72 |
my $job_type = 'batch_biblio_record_modification'; |
| 73 |
$conn->subscribe({ destination => $job_type, ack => 'client' }); |
| 74 |
my @frames; |
| 75 |
while (my $frame = $conn->receive_frame({timeout => 1})) { |
| 76 |
last unless $frame; |
| 77 |
my $body = $frame->body; |
| 78 |
my $args = decode_json($body); |
| 79 |
push @pending_jobs, $args->{job_id}; |
| 80 |
push @frames, $frame; |
| 81 |
} |
| 82 |
$conn->nack( { frame => $_ } ) for @frames; |
| 83 |
$conn->disconnect; |
| 84 |
} catch { |
| 85 |
push @messages, { |
| 86 |
type => 'error', |
| 87 |
code => 'cannot_retrieve_jobs', |
| 88 |
error => $_, |
| 89 |
}; |
| 90 |
}; |
| 91 |
|
| 92 |
$template->param( jobs => $jobs, pending_jobs => \@pending_jobs, ); |
| 68 |
} |
93 |
} |
| 69 |
|
94 |
|
| 70 |
$template->param( |
95 |
$template->param( |