use base qw(Bugzilla::WebService);
use Bugzilla::Constants;
+use Bugzilla::Error;
+use Bugzilla::Logging;
use Bugzilla::Util qw(datetime_from);
+use Try::Tiny;
use DateTime;
timezone
time
version
+ jobqueue_status
);
use constant PUBLIC_METHODS => qw(
time
timezone
version
+ jobqueue_status
);
sub version {
};
}
+sub jobqueue_status {
+ my ( $self, $params ) = @_;
+
+ Bugzilla->login(LOGIN_REQUIRED);
+
+ my $dbh = Bugzilla->dbh;
+ my $query = q{
+ SELECT
+ COUNT(*) AS total,
+ COALESCE(
+ (SELECT COUNT(*)
+ FROM ts_error
+ WHERE ts_error.jobid = j.jobid
+ )
+ , 0) AS errors
+ FROM ts_job j
+ INNER JOIN ts_funcmap f
+ ON f.funcid = j.funcid;
+ };
+
+ my $status;
+ try {
+ $status = $dbh->selectrow_hashref($query);
+ $status->{errors} = 0 + $status->{errors};
+ $status->{total} = 0 + $status->{total};
+ } catch {
+ ERROR($_);
+ ThrowCodeError('jobqueue_status_error');
+ };
+
+ return $status;
+}
+
1;
__END__
# BugUserLastVisited errors
user_not_involved => 1300,
+ # Job queue errors 1400-1500
+ jobqueue_status_error => 1400,
+
# Errors thrown by the WebService itself. The ones that are negative
# conform to http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php
xmlrpc_invalid_value => -32600,
GET => {
method => 'parameters'
}
+ },
+ qr{^/jobqueue_status$}, {
+ GET => {
+ method => 'jobqueue_status'
+ }
}
];
return $rest_resources;
=============== ====== ====================================================
last_audit_time string The maximum of the at_time from the audit_log.
=============== ====== ====================================================
+
+Job Queue Status
+----------------
+
+Reports the status of the job queue.
+
+**Request**
+
+.. code-block:: text
+
+ GET /rest/jobqueue_status
+
+This method requires an authenticated user.
+
+**Response**
+
+.. code-block:: js
+
+ {
+ "total": 12,
+ "errors": 0
+ }
+
+=============== ======= ====================================================
+name type description
+=============== ======= ====================================================
+total integer The total number of jobs in the job queue.
+errors integer The number of errors produced by jobs in the queue.
+=============== ======= ====================================================
\ No newline at end of file
to the <code>JOB_MAP</code> constant in <code>Bugzilla::JobQueue</code>,
perhaps by using the 'job_map' hook.
+ [% ELSIF error == "jobqueue_status_error" %]
+ An error occurred while checking the job queue status. Try again at a
+ later time.
+
[% ELSIF error == "ldap_bind_failed" %]
Failed to bind to the LDAP server. The error message was:
<code>[% errstr FILTER html %]</code>