MediaWiki  master
showJobs.php
Go to the documentation of this file.
00001 <?php
00028 require_once( __DIR__ . '/Maintenance.php' );
00029 
00036 class ShowJobs extends Maintenance {
00037         public function __construct() {
00038                 parent::__construct();
00039                 $this->mDescription = "Show number of jobs waiting in master database";
00040                 $this->addOption( 'group', 'Show number of jobs per job type' );
00041         }
00042         public function execute() {
00043                 $dbw = wfGetDB( DB_MASTER );
00044                 if ( $this->hasOption( 'group' ) ) {
00045                         $res = $dbw->select(
00046                                 'job',
00047                                 array( 'job_cmd', 'count(*) as count' ),
00048                                 array(),
00049                                 __METHOD__,
00050                                 array( 'GROUP BY' => 'job_cmd' )
00051                         );
00052                         foreach ( $res as $row ) {
00053                                 $this->output( $row->job_cmd . ': ' . $row->count . "\n" );
00054                         }
00055                 } else {
00056                         $this->output( $dbw->selectField( 'job', 'count(*)', '', __METHOD__ ) . "\n" );
00057                 }
00058         }
00059 }
00060 
00061 $maintClass = "ShowJobs";
00062 require_once( RUN_MAINTENANCE_IF_MAIN );