Aaron Schulz has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/165604

Change subject: Added a --type filter to showJobs.php
......................................................................

Added a --type filter to showJobs.php

Change-Id: I43d2c9fb949d88364dd000e9892a60ac19412e31
---
M maintenance/showJobs.php
1 file changed, 13 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/04/165604/1

diff --git a/maintenance/showJobs.php b/maintenance/showJobs.php
index b8dc554..a9f7d8b 100644
--- a/maintenance/showJobs.php
+++ b/maintenance/showJobs.php
@@ -38,16 +38,19 @@
                parent::__construct();
                $this->mDescription = "Show number of jobs waiting in master 
database";
                $this->addOption( 'group', 'Show number of jobs per job type' );
-               $this->addOption(
-                       'list',
-                       'Show a complete list of all jobs in a machine-readable 
format, instead of statistics'
-               );
+               $this->addOption( 'list',
+                       'Show a list of all jobs in a machine-readable format, 
instead of statistics' );
+               $this->addOption( 'type', 'Only show/count jobs of a given 
type', false, true );
        }
 
        public function execute() {
+               $filterType = $this->getOption( 'type', '' );
                $group = JobQueueGroup::singleton();
                if ( $this->hasOption( 'list' ) ) {
                        foreach ( $group->getQueueTypes() as $type ) {
+                               if ( $filterType != '' && $type != $filterType 
) {
+                                       continue;
+                               }
                                $queue = $group->get( $type );
                                foreach ( $queue->getAllQueuedJobs() as $job ) {
                                        $this->output( $job->toString() . " 
status=unclaimed\n" );
@@ -58,6 +61,9 @@
                        }
                } elseif ( $this->hasOption( 'group' ) ) {
                        foreach ( $group->getQueueTypes() as $type ) {
+                               if ( $filterType != '' && $type != $filterType 
) {
+                                       continue;
+                               }
                                $queue = $group->get( $type );
                                $delayed = $queue->getDelayedCount();
                                $pending = $queue->getSize();
@@ -75,6 +81,9 @@
                } else {
                        $count = 0;
                        foreach ( $group->getQueueTypes() as $type ) {
+                               if ( $filterType != '' && $type != $filterType 
) {
+                                       continue;
+                               }
                                $count += $group->get( $type )->getSize();
                        }
                        $this->output( "$count\n" );

-- 
To view, visit https://gerrit.wikimedia.org/r/165604
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I43d2c9fb949d88364dd000e9892a60ac19412e31
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Aaron Schulz <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to