View | Details | Raw Unified | Return to bug 22417
Collapse All | Expand All

(-)a/admin/background_jobs.pl (-1 / +26 lines)
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(
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/background_jobs.tt (-2 / +12 lines)
Lines 21-28 Link Here
21
            <main>
21
            <main>
22
22
23
[% FOR m IN messages %]
23
[% FOR m IN messages %]
24
    <div class="dialog [% m.type | html %]">
24
    <div class="dialog message">
25
        [% SWITCH m.code %]
25
        [% SWITCH m.code %]
26
        [% CASE 'cannot_retrieve_jobs' %]
27
            <div><i class="fa fa-exclamation error"></i>Cannot retrieve pending jobs ([% m.error %])</div>
26
        [% CASE %]
28
        [% CASE %]
27
            [% m.code | html %]
29
            [% m.code | html %]
28
        [% END %]
30
        [% END %]
Lines 109-114 Link Here
109
111
110
    <h2>Background jobs</h2>
112
    <h2>Background jobs</h2>
111
113
114
    <div class="dialog message">
115
        <i class="fa fa-info"></i>
116
        [% IF pending_jobs.size > 0 %]
117
            There is [% pending_jobs.size %] pending jobs on the server: [% pending_jobs.join(', ') %].
118
        [% ELSE %]
119
            There is no pending jobs on the server.
120
        [% END %]
121
    </div>
122
112
    [% IF jobs.count %]
123
    [% IF jobs.count %]
113
        <table id="table_background_jobs">
124
        <table id="table_background_jobs">
114
            <thead>
125
            <thead>
115
- 

Return to bug 22417