summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
authorDylan William Hardison <dylan@hardison.net>2018-04-08 17:59:51 +0200
committerDylan William Hardison <dylan@hardison.net>2018-04-08 17:59:51 +0200
commit3cf92acb65f76fd5a922a6fbba4ef936cb01b2c3 (patch)
treecab8da7430ea1fb1fe5647940d65dbeaaf9e0a98 /Bugzilla
parentf6013b2b6a26a23c6d06c1ee6748bc4515e83903 (diff)
parent755bc194dcea3481fa41b5884a98a5aa086fe09e (diff)
downloadbugzilla-3cf92acb65f76fd5a922a6fbba4ef936cb01b2c3.tar.gz
bugzilla-3cf92acb65f76fd5a922a6fbba4ef936cb01b2c3.tar.xz
Merge remote-tracking branch 'bmo/master' into unstable
Diffstat (limited to 'Bugzilla')
-rw-r--r--Bugzilla/JobQueue.pm7
-rw-r--r--Bugzilla/WebService/Bugzilla.pm38
-rw-r--r--Bugzilla/WebService/Constants.pm3
-rw-r--r--Bugzilla/WebService/Server/REST/Resources/Bugzilla.pm5
4 files changed, 52 insertions, 1 deletions
diff --git a/Bugzilla/JobQueue.pm b/Bugzilla/JobQueue.pm
index 53b088c6e..afb36673f 100644
--- a/Bugzilla/JobQueue.pm
+++ b/Bugzilla/JobQueue.pm
@@ -101,7 +101,12 @@ sub debug {
my $caller_pkg = caller;
local $Log::Log4perl::caller_depth = $Log::Log4perl::caller_depth + 1;
my $logger = Log::Log4perl->get_logger($caller_pkg);
- $logger->info(@args);
+ if ($args[0] && $args[0] eq "TheSchwartz::work_once found no jobs") {
+ $logger->trace(@args);
+ }
+ else {
+ $logger->info(@args);
+ }
}
sub work {
diff --git a/Bugzilla/WebService/Bugzilla.pm b/Bugzilla/WebService/Bugzilla.pm
index 0d0393c28..145502445 100644
--- a/Bugzilla/WebService/Bugzilla.pm
+++ b/Bugzilla/WebService/Bugzilla.pm
@@ -13,7 +13,10 @@ use warnings;
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;
@@ -28,6 +31,7 @@ use constant READ_ONLY => qw(
timezone
time
version
+ jobqueue_status
);
use constant PUBLIC_METHODS => qw(
@@ -35,6 +39,7 @@ use constant PUBLIC_METHODS => qw(
time
timezone
version
+ jobqueue_status
);
sub version {
@@ -80,6 +85,39 @@ sub time {
};
}
+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__
diff --git a/Bugzilla/WebService/Constants.pm b/Bugzilla/WebService/Constants.pm
index 93fddfc2b..71435c13a 100644
--- a/Bugzilla/WebService/Constants.pm
+++ b/Bugzilla/WebService/Constants.pm
@@ -199,6 +199,9 @@ use constant WS_ERROR_CODE => {
# 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,
diff --git a/Bugzilla/WebService/Server/REST/Resources/Bugzilla.pm b/Bugzilla/WebService/Server/REST/Resources/Bugzilla.pm
index a8f3f9330..646355cd3 100644
--- a/Bugzilla/WebService/Server/REST/Resources/Bugzilla.pm
+++ b/Bugzilla/WebService/Server/REST/Resources/Bugzilla.pm
@@ -49,6 +49,11 @@ sub _rest_resources {
GET => {
method => 'parameters'
}
+ },
+ qr{^/jobqueue_status$}, {
+ GET => {
+ method => 'jobqueue_status'
+ }
}
];
return $rest_resources;