#969 add job queue totals to report

This commit is contained in:
Oliver Gorwits
2023-10-24 20:03:14 +01:00
parent fb58b62b1a
commit ae3ad986f7
3 changed files with 25 additions and 1 deletions

View File

@@ -22,10 +22,27 @@ ajax '/ajax/control/admin/jobqueue/delall' => require_role admin => sub {
jq_delete();
};
sub commify {
my $text = reverse $_[0];
$text =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1,/g;
return scalar reverse $text;
}
ajax '/ajax/content/admin/jobqueue' => require_role admin => sub {
content_type('text/html');
my $jq_total = schema(vars->{'tenant'})->resultset('Admin')->count();
my $jq_queued = schema(vars->{'tenant'})->resultset('Admin')->search({status => 'queued'})->count();
my $jq_running = schema(vars->{'tenant'})->resultset('Admin')->search({status => { -like => 'queued-%'}})->count();
my $jq_done = schema(vars->{'tenant'})->resultset('Admin')->search({status => 'done'})->count();
my $jq_errored = schema(vars->{'tenant'})->resultset('Admin')->search({status => 'error'})->count();
template 'ajax/admintask/jobqueue.tt', {
jq_total => commify($jq_total || 0),
jq_queued => commify($jq_queued || 0),
jq_running => commify($jq_running || 0),
jq_done => commify($jq_done || 0),
jq_errored => commify($jq_errored || 0),
results => [ jq_log ],
}, { layout => undef };
};

View File

@@ -171,7 +171,7 @@ sidebar_defaults:
device_port_col_idx_left: 8
device_port_col_idx_mid: 20
device_port_col_idx_right: 24
jobqueue_refresh: 10
jobqueue_refresh: 5
safe_password_store: true
reports: []
system_reports:

View File

@@ -1,6 +1,13 @@
[% IF NOT results.size %]
<div class="span2 alert alert-info">The job queue is empty.</div>
[% ELSE %]
<div class="alert alert-info">
Total: [% jq_total | html_entity %] /
Queued: [% jq_queued | html_entity %] /
Running: [% jq_running | html_entity %] /
Done: [% jq_done | html_entity %] /
Errored: [% jq_errored | html_entity %]
</div>
<table class="table table-bordered table-condensed table-hover nd_floatinghead">
<thead>
<tr>