Unicornisaurous has uploaded a new change for review.
https://gerrit.wikimedia.org/r/258769
Change subject: Show the number of MassAction jobs queued on Special:Statistics
......................................................................
Show the number of MassAction jobs queued on Special:Statistics
Bug: T96562
Change-Id: I7f66b733efc0c8863dbb91e85ea4ce36f2583eac
---
M MassAction.php
M i18n/en.json
M i18n/qqq.json
A src/MassAction.php
M src/MassActionHooks.php
5 files changed, 48 insertions(+), 2 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MassAction
refs/changes/69/258769/1
diff --git a/MassAction.php b/MassAction.php
index bac9cf7..876ef2a 100644
--- a/MassAction.php
+++ b/MassAction.php
@@ -71,6 +71,7 @@
$wgHooks['LoadExtensionSchemaUpdates'][] =
'MassAction\\MassActionHooks::onLoadExtensionSchemaUpdates';
$wgHooks['UnitTestsList'][] =
'MassAction\\MassActionHooks::onUnitTestsList';
+ $wgHooks['SpecialStatsAddExtra'][] =
'MassAction\\MassActionHooks::onSpecialStatsAddExtra';
# Add own log type
global $wgLogTypes;
diff --git a/i18n/en.json b/i18n/en.json
index ceb4645..8cc2e6a 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -19,5 +19,6 @@
"massaction-specialpage-general-section":"General options",
"massaction-specialpage-matchers-section":"Matchers",
"massaction-specialpage-actions-section":"Actions",
- "massaction-target-wikipage-titleregexmatcher-regex-help":"Regex
characters allowed: . * ?"
+ "massaction-target-wikipage-titleregexmatcher-regex-help":"Regex
characters allowed: . * ?",
+ "massaction-queued-count": "Queued [[Special:MassAction|mass action]]
jobs"
}
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 32bbf85..3e1ad0c 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -21,5 +21,6 @@
"massaction-specialpage-general-section": "Title for the section
containing general options when creating a new task",
"massaction-specialpage-matchers-section": "Title for the section
containing options for Matchers when creating a new task",
"massaction-specialpage-actions-section": "Title for the section
containing options for Actions when creating a new task\n{{Identical|Action}}",
- "massaction-target-wikipage-titleregexmatcher-regex-help": "Help
message for the WikiPage TitleRegexMatcher Regex form entry box"
+ "massaction-target-wikipage-titleregexmatcher-regex-help": "Help
message for the WikiPage TitleRegexMatcher Regex form entry box",
+ "massaction-queued-count": "Text for row on [[Special:Statistics]]."
}
diff --git a/src/MassAction.php b/src/MassAction.php
new file mode 100644
index 0000000..d239fc3
--- /dev/null
+++ b/src/MassAction.php
@@ -0,0 +1,33 @@
+<?php
+
+namespace MassAction;
+use JobQueueGroup;
+/**
+ * Utility functions used by the extension
+ *
+ * @licence GNU GPL v2+
+ */
+
+class MassAction {
+
+ /**
+ * Get the number of Queued messages on this site
+ * Taken from runJobs.php --group
+ * @return int
+ */
+ public static function getTotalQueuedJobsCount() {
+ $group = JobQueueGroup::singleton();
+ $jobNames = array( "massActionChangeSaverJob",
"massActionChangeSaverSpawnerJob", "massActionTargetListJob" );
+ $total = 0;
+ foreach ( $jobNames as $name ) {
+ $queue = $group->get( $name );
+ $pending = $queue->getSize();
+ $claimed = $queue->getAcquiredCount();
+ $abandoned = $queue->getAbandonedCount();
+ $active = max( $claimed - $abandoned, 0 );
+ $total += $active + $pending;
+ }
+ return $total;
+ }
+}
+
diff --git a/src/MassActionHooks.php b/src/MassActionHooks.php
index e15f430..d1b8fb7 100644
--- a/src/MassActionHooks.php
+++ b/src/MassActionHooks.php
@@ -44,4 +44,14 @@
return true;
}
+ /**
+ * Add a row with the number of queued messages to Special:Statistics
+ * @param array $extraStats
+ * @return bool
+ */
+ public static function onSpecialStatsAddExtra( &$extraStats ) {
+ $extraStats['massaction-queued-count'] =
MassAction::getTotalQueuedJobsCount();
+ return true;
+ }
+
}
--
To view, visit https://gerrit.wikimedia.org/r/258769
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I7f66b733efc0c8863dbb91e85ea4ce36f2583eac
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MassAction
Gerrit-Branch: master
Gerrit-Owner: Unicornisaurous <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits