From: Alexandre Emsenhuber Date: Fri, 14 Aug 2009 11:15:47 +0000 (+0000) Subject: Added --group option to show number of jobs per job type X-Git-Tag: 1.31.0-rc.0~40310 X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=commitdiff_plain;h=0ad2053160689bcba07f2bd8bb1abfe4b784d344;p=lhc%2Fweb%2Fwiklou.git Added --group option to show number of jobs per job type --- 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" ); + } } }