summaryrefslogtreecommitdiffstats
path: root/view_job_queue.cgi
diff options
context:
space:
mode:
Diffstat (limited to 'view_job_queue.cgi')
-rwxr-xr-xview_job_queue.cgi106
1 files changed, 54 insertions, 52 deletions
diff --git a/view_job_queue.cgi b/view_job_queue.cgi
index 5ea871104..a8e585e1a 100755
--- a/view_job_queue.cgi
+++ b/view_job_queue.cgi
@@ -21,9 +21,8 @@ use Storable qw(read_magic thaw);
my $user = Bugzilla->login(LOGIN_REQUIRED);
($user->in_group("admin") || $user->in_group('infra'))
- || ThrowUserError("auth_failure", { group => "admin",
- action => "access",
- object => "job_queue" });
+ || ThrowUserError("auth_failure",
+ {group => "admin", action => "access", object => "job_queue"});
my $vars = {};
generate_report($vars);
@@ -31,14 +30,14 @@ generate_report($vars);
print Bugzilla->cgi->header();
my $template = Bugzilla->template;
$template->process('admin/reports/job_queue.html.tmpl', $vars)
- || ThrowTemplateError($template->error());
+ || ThrowTemplateError($template->error());
sub generate_report {
- my ($vars) = @_;
- my $dbh = Bugzilla->dbh;
- my $user = Bugzilla->user;
+ my ($vars) = @_;
+ my $dbh = Bugzilla->dbh;
+ my $user = Bugzilla->user;
- my $query = "
+ my $query = "
SELECT
j.jobid,
j.arg,
@@ -66,56 +65,59 @@ sub generate_report {
j.run_after, j.grabbed_until, j.insert_time, j.jobid
" . $dbh->sql_limit(JOB_QUEUE_VIEW_MAX_JOBS + 1);
- $vars->{jobs} = $dbh->selectall_arrayref($query, { Slice => {} });
- if (@{ $vars->{jobs} } == JOB_QUEUE_VIEW_MAX_JOBS + 1) {
- pop @{ $vars->{jobs} };
- $vars->{job_count} = $dbh->selectrow_array("SELECT COUNT(*) FROM ts_job");
- $vars->{too_many_jobs} = 1;
- }
+ $vars->{jobs} = $dbh->selectall_arrayref($query, {Slice => {}});
+ if (@{$vars->{jobs}} == JOB_QUEUE_VIEW_MAX_JOBS + 1) {
+ pop @{$vars->{jobs}};
+ $vars->{job_count} = $dbh->selectrow_array("SELECT COUNT(*) FROM ts_job");
+ $vars->{too_many_jobs} = 1;
+ }
- my $bug_word = template_var('terms')->{bug};
- foreach my $job (@{ $vars->{jobs} }) {
- my ($recipient, $description);
- eval {
- if ($job->{func} eq 'Bugzilla::Job::BugMail') {
- my $arg = _cond_thaw(delete $job->{arg});
- next unless $arg;
- my $vars = $arg->{vars};
- $recipient = $vars->{to_user}->{login_name};
- $description = "[$bug_word " . $vars->{bug}->{bug_id} . '] '
- . $vars->{bug}->{short_desc};
- }
+ my $bug_word = template_var('terms')->{bug};
+ foreach my $job (@{$vars->{jobs}}) {
+ my ($recipient, $description);
+ eval {
+ if ($job->{func} eq 'Bugzilla::Job::BugMail') {
+ my $arg = _cond_thaw(delete $job->{arg});
+ next unless $arg;
+ my $vars = $arg->{vars};
+ $recipient = $vars->{to_user}->{login_name};
+ $description
+ = "[$bug_word " . $vars->{bug}->{bug_id} . '] ' . $vars->{bug}->{short_desc};
+ }
- elsif ($job->{func} eq 'Bugzilla::Job::Mailer') {
- my $arg = _cond_thaw(delete $job->{arg});
- next unless $arg;
- my $msg = $arg->{msg};
- if (ref($msg) && blessed($msg) eq 'Email::MIME') {
- $recipient = $msg->header('to');
- $description = $msg->header('subject');
- } else {
- ($recipient) = $msg =~ /\nTo: ([^\n]+)/i;
- ($description) = $msg =~ /\nSubject: ([^\n]+)/i;
- }
- }
- };
- if ($recipient) {
- $job->{subject} = "<$recipient> $description";
+ elsif ($job->{func} eq 'Bugzilla::Job::Mailer') {
+ my $arg = _cond_thaw(delete $job->{arg});
+ next unless $arg;
+ my $msg = $arg->{msg};
+ if (ref($msg) && blessed($msg) eq 'Email::MIME') {
+ $recipient = $msg->header('to');
+ $description = $msg->header('subject');
+ }
+ else {
+ ($recipient) = $msg =~ /\nTo: ([^\n]+)/i;
+ ($description) = $msg =~ /\nSubject: ([^\n]+)/i;
}
+ }
+ };
+ if ($recipient) {
+ $job->{subject} = "<$recipient> $description";
}
+ }
}
sub _cond_thaw {
- my $data = shift;
- my $magic = eval { read_magic($data); };
- if ($magic && $magic->{major} && $magic->{major} >= 2 && $magic->{major} <= 5) {
- my $thawed = eval { thaw($data) };
- if ($@) {
- # false alarm... looked like a Storable, but wasn't
- return undef;
- }
- return $thawed;
- } else {
- return undef;
+ my $data = shift;
+ my $magic = eval { read_magic($data); };
+ if ($magic && $magic->{major} && $magic->{major} >= 2 && $magic->{major} <= 5) {
+ my $thawed = eval { thaw($data) };
+ if ($@) {
+
+ # false alarm... looked like a Storable, but wasn't
+ return undef;
}
+ return $thawed;
+ }
+ else {
+ return undef;
+ }
}