Niharika29 has uploaded a new change for review.
https://gerrit.wikimedia.org/r/259684
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
2 files changed, 56 insertions(+), 31 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Gadgets
refs/changes/84/259684/1
diff --git a/SpecialGadgetUsage.php b/SpecialGadgetUsage.php
index ebdf961..c51362a 100644
--- a/SpecialGadgetUsage.php
+++ b/SpecialGadgetUsage.php
@@ -33,6 +33,7 @@
parent::__construct( $name );
$this->limit = 1000; // Show all gadgets
$this->shownavigation = false;
+ $this->activeUsers = $this->getConfig()->get(
'SpecialGadgetUsageActiveUsers' );
}
public function isExpensive() {
@@ -50,35 +51,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 == false ) {
+ 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 +110,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 == true ) {
+ $headers[] = 'gadgetusage-activeusers';
+ }
foreach( $headers as $h ) {
$html .= Html::element( 'th', array(), $this->msg( $h
)->text() );
}
@@ -109,12 +129,16 @@
public function formatResult( $skin, $result ) {
$gadgetTitle = substr( $result->title, 7 );
$gadgetUserCount = $this->getLanguage()->formatNum(
$result->value );
- $activeUsers = $this->getLanguage()->formatNum(
$result->namespace );
+ if ( $this->activeUsers == true ) {
+ $activeUserCount = $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 ) {
+ $html .= Html::element( 'td', array(),
$activeUserCount );
+ }
$html .= Html::closeElement( 'tr' );
return $html;
}
diff --git a/extension.json b/extension.json
index 92576c3..cd82941 100644
--- a/extension.json
+++ b/extension.json
@@ -111,7 +111,8 @@
]
},
"config": {
- "GadgetsRepoClass": "MediaWikiGadgetsDefinitionRepo"
+ "GadgetsRepoClass": "MediaWikiGadgetsDefinitionRepo",
+ "SpecialGadgetUsageActiveUsers": false
},
"manifest_version": 1
}
--
To view, visit https://gerrit.wikimedia.org/r/259684
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Idcf2a8a1cdf5ce4c2f6a631ef980be5a48ca547b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Gadgets
Gerrit-Branch: master
Gerrit-Owner: Niharika29 <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits