Index: trunk/phase3/maintenance/showJobs.php |
— | — | @@ -30,10 +30,24 @@ |
31 | 31 | public function __construct() { |
32 | 32 | parent::__construct(); |
33 | 33 | $this->mDescription = "Show number of jobs waiting in master database"; |
| 34 | + $this->addOption( 'group', 'Show number of jobs per job type' ); |
34 | 35 | } |
35 | 36 | public function execute() { |
36 | 37 | $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 | + } |
38 | 52 | } |
39 | 53 | } |
40 | 54 | |