jenkins-bot has submitted this change and it was merged.
Change subject: Add a feature flag to turn off the 'active users' query on
GadgetUsage
......................................................................
Add a feature flag to turn off the 'active users' query on GadgetUsage
Currently takes >24 hours to complete on enwiki and thus isn't run
at all. Need a better optimised query. Until that happens, we can
turn it off on enwiki.
Bug: T121484
Change-Id: Idcf2a8a1cdf5ce4c2f6a631ef980be5a48ca547b
---
M SpecialGadgetUsage.php
M extension.json
M i18n/en.json
M i18n/qqq.json
4 files changed, 77 insertions(+), 35 deletions(-)
Approvals:
Kaldari: Looks good to me, approved
jenkins-bot: Verified
diff --git a/SpecialGadgetUsage.php b/SpecialGadgetUsage.php
index bcd6b88..34abe26 100644
--- a/SpecialGadgetUsage.php
+++ b/SpecialGadgetUsage.php
@@ -33,7 +33,17 @@
parent::__construct( $name );
$this->limit = 1000; // Show all gadgets
$this->shownavigation = false;
+ $this->activeUsers = $this->getConfig()->get(
'SpecialGadgetUsageActiveUsers' );
}
+
+
+ /**
+ * Flag for holding the value of config variable
SpecialGadgetUsageActiveUsers
+ *
+ * @var bool $activeUsers
+ */
+ public $activeUsers;
+
public function isExpensive() {
return true;
@@ -50,35 +60,52 @@
*/
public function getQueryInfo() {
$dbr = wfGetDB( DB_SLAVE );
- return array(
- 'tables' => array( 'user_properties', 'user',
'querycachetwo' ),
- 'fields' => array(
- 'title' => 'up_property',
- 'value' => 'SUM( up_value )',
- // Need to pick fields existing in the
querycache table so that the results are cachable
- 'namespace' => 'COUNT( qcc_title )'
- ),
- 'conds' => array(
- 'up_property' . $dbr->buildLike( 'gadget-',
$dbr->anyString() )
- ),
- 'options' => array(
- 'GROUP BY' => array( 'up_property' )
- ),
- 'join_conds' => array(
- 'user' => array(
- 'LEFT JOIN', array(
- 'up_user = user_id'
- )
+ if ( !$this->activeUsers ) {
+ return array(
+ 'tables' => array( 'user_properties' ),
+ 'fields' => array(
+ 'title' => 'up_property',
+ 'value' => 'SUM( up_value )',
+ 'namespace' => NS_GADGET
),
- 'querycachetwo' => array(
- 'LEFT JOIN', array(
- 'user_name = qcc_title',
- 'qcc_type = "activeusers"',
- 'up_value = 1'
+ 'conds' => array(
+ 'up_property' . $dbr->buildLike(
'gadget-', $dbr->anyString() )
+ ),
+ 'options' => array(
+ 'GROUP BY' => array( 'up_property' )
+ )
+ );
+ } else {
+ return array(
+ 'tables' => array( 'user_properties', 'user',
'querycachetwo' ),
+ 'fields' => array(
+ 'title' => 'up_property',
+ 'value' => 'SUM( up_value )',
+ // Need to pick fields existing in the
querycache table so that the results are cachable
+ 'namespace' => 'COUNT( qcc_title )'
+ ),
+ 'conds' => array(
+ 'up_property' . $dbr->buildLike(
'gadget-', $dbr->anyString() )
+ ),
+ 'options' => array(
+ 'GROUP BY' => array( 'up_property' )
+ ),
+ 'join_conds' => array(
+ 'user' => array(
+ 'LEFT JOIN', array(
+ 'up_user = user_id'
+ )
+ ),
+ 'querycachetwo' => array(
+ 'LEFT JOIN', array(
+ 'user_name = qcc_title',
+ 'qcc_type =
"activeusers"',
+ 'up_value = 1'
+ )
)
)
- )
- );
+ );
+ }
}
public function getOrderFields() {
@@ -92,8 +119,10 @@
protected function outputTableStart() {
$html = Html::openElement( 'table', array( 'class' => array(
'sortable', 'wikitable' ) ) );
$html .= Html::openElement( 'tr', array() );
-
- $headers = array( 'gadgetusage-gadget',
'gadgetusage-usercount', 'gadgetusage-activeusers' );
+ $headers = array( 'gadgetusage-gadget', 'gadgetusage-usercount'
);
+ if ( $this->activeUsers ) {
+ $headers[] = 'gadgetusage-activeusers';
+ }
foreach( $headers as $h ) {
$html .= Html::element( 'th', array(), $this->msg( $h
)->text() );
}
@@ -109,12 +138,14 @@
public function formatResult( $skin, $result ) {
$gadgetTitle = substr( $result->title, 7 );
$gadgetUserCount = $this->getLanguage()->formatNum(
$result->value );
- $activeUsers = $this->getLanguage()->formatNum(
$result->namespace );
if ( $gadgetTitle ) {
$html = Html::openElement( 'tr', array() );
$html .= Html::element( 'td', array(), $gadgetTitle );
$html .= Html::element( 'td', array(), $gadgetUserCount
);
- $html .= Html::element( 'td', array(), $activeUsers );
+ if ( $this->activeUsers == true ) {
+ $activeUserCount =
$this->getLanguage()->formatNum( $result->namespace );
+ $html .= Html::element( 'td', array(),
$activeUserCount );
+ }
$html .= Html::closeElement( 'tr' );
return $html;
}
@@ -154,9 +185,15 @@
$gadgetRepo = GadgetRepo::singleton();
$gadgetIds = $gadgetRepo->getGadgetIds();
$defaultGadgets = $this->getDefaultGadgets( $gadgetRepo,
$gadgetIds );
- $out->addHtml(
- $this->msg( 'gadgetusage-intro',
$this->getConfig()->get( 'ActiveUserDays' ) )->parseAsBlock()
- );
+ if ( $this->activeUsers ) {
+ $out->addHtml(
+ $this->msg( 'gadgetusage-intro',
$this->getConfig()->get( 'ActiveUserDays' ) )->parseAsBlock()
+ );
+ } else {
+ $out->addHtml(
+ $this->msg( 'gadgetusage-intro-noactive'
)->parseAsBlock()
+ );
+ }
if ( $num > 0 ) {
$this->outputTableStart();
// Append default gadgets to the table with 'default'
in the total and active user fields
@@ -164,7 +201,9 @@
$html = Html::openElement( 'tr', array() );
$html .= Html::element( 'td', array(), $default
);
$html .= Html::element( 'td', array(),
$this->msg( 'gadgetusage-default' ) );
- $html .= Html::element( 'td', array(),
$this->msg( 'gadgetusage-default' ) );
+ if ( $this->activeUsers ) {
+ $html .= Html::element( 'td', array(),
$this->msg( 'gadgetusage-default' ) );
+ }
$html .= Html::closeElement( 'tr' );
$out->addHTML( $html );
}
diff --git a/extension.json b/extension.json
index 92576c3..268e6c2 100644
--- a/extension.json
+++ b/extension.json
@@ -111,7 +111,8 @@
]
},
"config": {
- "GadgetsRepoClass": "MediaWikiGadgetsDefinitionRepo"
+ "GadgetsRepoClass": "MediaWikiGadgetsDefinitionRepo",
+ "SpecialGadgetUsageActiveUsers": true
},
"manifest_version": 1
}
diff --git a/i18n/en.json b/i18n/en.json
index ef781e5..08abfbb 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -13,6 +13,7 @@
"gadgetusage-usercount": "Number of users",
"gadgetusage-noresults": "No gadgets found.",
"gadgetusage-intro": "This table indicates the number of users who have
enabled each gadget on this wiki. An active user is counted as someone who has
made an edit in the last {{PLURAL:$1|day|$1 days}}. This list excludes stats
for gadgets enabled for everyone by default and may include gadgets that are no
longer available.",
+ "gadgetusage-intro-noactive": "This table indicates the number of users
who have enabled each gadget on this wiki. This list excludes stats for gadgets
enabled for everyone by default and may include gadgets that are no longer
available.",
"gadgetusage-activeusers": "Active users",
"gadgetusage-default": "Default",
"gadgets-definition": "",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 02d5460..f658105 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -25,6 +25,7 @@
"gadgetusage-usercount": "Table column header on
[[Special:GadgetUsage]]",
"gadgetusage-noresults": "Message shown to user when no gadgets found
installed on the wiki. Used on [[Special:GadgetUsage]]",
"gadgetusage-intro": "Intro text on [[Special:GadgetUsage]]
Parameter:\n* $1 - the number of days to consider for defining a user as
active",
+ "gadgetusage-intro-noactive": "Intro text on [[Special:GadgetUsage]]",
"gadgetusage-activeusers": "Table column header for active users using
a gadget",
"gadgetusage-default": "Message to indicate the gadget is default and
actual stats are not available",
"gadgets-definition": "{{notranslate}}",
--
To view, visit https://gerrit.wikimedia.org/r/259684
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Idcf2a8a1cdf5ce4c2f6a631ef980be5a48ca547b
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/Gadgets
Gerrit-Branch: master
Gerrit-Owner: Niharika29 <[email protected]>
Gerrit-Reviewer: Kaldari <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits