From 0ad2053160689bcba07f2bd8bb1abfe4b784d344 Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Fri, 14 Aug 2009 11:15:47 +0000 Subject: [PATCH] Added --group option to show number of jobs per job type --- maintenance/showJobs.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/maintenance/showJobs.php b/maintenance/showJobs.php index beff294d22..b385c50ac7 100644 --- a/maintenance/showJobs.php +++ b/maintenance/showJobs.php @@ -30,10 +30,24 @@ class ShowJobs extends Maintenance { public function __construct() { parent::__construct(); $this->mDescription = "Show number of jobs waiting in master database"; + $this->addOption( 'group', 'Show number of jobs per job type' ); } public function execute() { $dbw = wfGetDB( DB_MASTER ); - $this->output( $dbw->selectField( 'job', 'count(*)', '', __METHOD__ ) . "\n" ); + if ( $this->hasOption( 'group' ) ) { + $res = $dbw->select( + 'job', + array( 'job_cmd', 'count(*) as count' ), + array(), + __METHOD__, + array( 'GROUP BY' => 'job_cmd' ) + ); + foreach( $res as $row ) { + $this->output( $row->job_cmd . ': ' . $row->count . "\n" ); + } + } else { + $this->output( $dbw->selectField( 'job', 'count(*)', '', __METHOD__ ) . "\n" ); + } } } -- 2.20.1