r55007 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r55006‎ | r55007 | r55008 >
Date:11:15, 14 August 2009
Author:ialex
Status:ok
Tags:
Comment:
Added --group option to show number of jobs per job type
Modified paths:
  • /trunk/phase3/maintenance/showJobs.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/showJobs.php
@@ -30,10 +30,24 @@
3131 public function __construct() {
3232 parent::__construct();
3333 $this->mDescription = "Show number of jobs waiting in master database";
 34+ $this->addOption( 'group', 'Show number of jobs per job type' );
3435 }
3536 public function execute() {
3637 $dbw = wfGetDB( DB_MASTER );
37 - $this->output( $dbw->selectField( 'job', 'count(*)', '', __METHOD__ ) . "\n" );
 38+ if ( $this->hasOption( 'group' ) ) {
 39+ $res = $dbw->select(
 40+ 'job',
 41+ array( 'job_cmd', 'count(*) as count' ),
 42+ array(),
 43+ __METHOD__,
 44+ array( 'GROUP BY' => 'job_cmd' )
 45+ );
 46+ foreach( $res as $row ) {
 47+ $this->output( $row->job_cmd . ': ' . $row->count . "\n" );
 48+ }
 49+ } else {
 50+ $this->output( $dbw->selectField( 'job', 'count(*)', '', __METHOD__ ) . "\n" );
 51+ }
3852 }
3953 }
4054

Status & tagging log