mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Gadgets
synced 2024-11-28 01:00:02 +00:00
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
This commit is contained in:
parent
97f6b1589a
commit
75ae3558e7
|
@ -33,8 +33,18 @@ class SpecialGadgetUsage extends QueryPage {
|
||||||
parent::__construct( $name );
|
parent::__construct( $name );
|
||||||
$this->limit = 1000; // Show all gadgets
|
$this->limit = 1000; // Show all gadgets
|
||||||
$this->shownavigation = false;
|
$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() {
|
public function isExpensive() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -50,6 +60,22 @@ class SpecialGadgetUsage extends QueryPage {
|
||||||
*/
|
*/
|
||||||
public function getQueryInfo() {
|
public function getQueryInfo() {
|
||||||
$dbr = wfGetDB( DB_SLAVE );
|
$dbr = wfGetDB( DB_SLAVE );
|
||||||
|
if ( !$this->activeUsers ) {
|
||||||
|
return array(
|
||||||
|
'tables' => array( 'user_properties' ),
|
||||||
|
'fields' => array(
|
||||||
|
'title' => 'up_property',
|
||||||
|
'value' => 'SUM( up_value )',
|
||||||
|
'namespace' => NS_GADGET
|
||||||
|
),
|
||||||
|
'conds' => array(
|
||||||
|
'up_property' . $dbr->buildLike( 'gadget-', $dbr->anyString() )
|
||||||
|
),
|
||||||
|
'options' => array(
|
||||||
|
'GROUP BY' => array( 'up_property' )
|
||||||
|
)
|
||||||
|
);
|
||||||
|
} else {
|
||||||
return array(
|
return array(
|
||||||
'tables' => array( 'user_properties', 'user', 'querycachetwo' ),
|
'tables' => array( 'user_properties', 'user', 'querycachetwo' ),
|
||||||
'fields' => array(
|
'fields' => array(
|
||||||
|
@ -80,6 +106,7 @@ class SpecialGadgetUsage extends QueryPage {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function getOrderFields() {
|
public function getOrderFields() {
|
||||||
return array( 'value' );
|
return array( 'value' );
|
||||||
|
@ -92,8 +119,10 @@ class SpecialGadgetUsage extends QueryPage {
|
||||||
protected function outputTableStart() {
|
protected function outputTableStart() {
|
||||||
$html = Html::openElement( 'table', array( 'class' => array( 'sortable', 'wikitable' ) ) );
|
$html = Html::openElement( 'table', array( 'class' => array( 'sortable', 'wikitable' ) ) );
|
||||||
$html .= Html::openElement( 'tr', array() );
|
$html .= Html::openElement( 'tr', array() );
|
||||||
|
$headers = array( 'gadgetusage-gadget', 'gadgetusage-usercount' );
|
||||||
$headers = array( 'gadgetusage-gadget', 'gadgetusage-usercount', 'gadgetusage-activeusers' );
|
if ( $this->activeUsers ) {
|
||||||
|
$headers[] = 'gadgetusage-activeusers';
|
||||||
|
}
|
||||||
foreach( $headers as $h ) {
|
foreach( $headers as $h ) {
|
||||||
$html .= Html::element( 'th', array(), $this->msg( $h )->text() );
|
$html .= Html::element( 'th', array(), $this->msg( $h )->text() );
|
||||||
}
|
}
|
||||||
|
@ -109,12 +138,14 @@ class SpecialGadgetUsage extends QueryPage {
|
||||||
public function formatResult( $skin, $result ) {
|
public function formatResult( $skin, $result ) {
|
||||||
$gadgetTitle = substr( $result->title, 7 );
|
$gadgetTitle = substr( $result->title, 7 );
|
||||||
$gadgetUserCount = $this->getLanguage()->formatNum( $result->value );
|
$gadgetUserCount = $this->getLanguage()->formatNum( $result->value );
|
||||||
$activeUsers = $this->getLanguage()->formatNum( $result->namespace );
|
|
||||||
if ( $gadgetTitle ) {
|
if ( $gadgetTitle ) {
|
||||||
$html = Html::openElement( 'tr', array() );
|
$html = Html::openElement( 'tr', array() );
|
||||||
$html .= Html::element( 'td', array(), $gadgetTitle );
|
$html .= Html::element( 'td', array(), $gadgetTitle );
|
||||||
$html .= Html::element( 'td', array(), $gadgetUserCount );
|
$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' );
|
$html .= Html::closeElement( 'tr' );
|
||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
|
@ -154,9 +185,15 @@ class SpecialGadgetUsage extends QueryPage {
|
||||||
$gadgetRepo = GadgetRepo::singleton();
|
$gadgetRepo = GadgetRepo::singleton();
|
||||||
$gadgetIds = $gadgetRepo->getGadgetIds();
|
$gadgetIds = $gadgetRepo->getGadgetIds();
|
||||||
$defaultGadgets = $this->getDefaultGadgets( $gadgetRepo, $gadgetIds );
|
$defaultGadgets = $this->getDefaultGadgets( $gadgetRepo, $gadgetIds );
|
||||||
|
if ( $this->activeUsers ) {
|
||||||
$out->addHtml(
|
$out->addHtml(
|
||||||
$this->msg( 'gadgetusage-intro', $this->getConfig()->get( 'ActiveUserDays' ) )->parseAsBlock()
|
$this->msg( 'gadgetusage-intro', $this->getConfig()->get( 'ActiveUserDays' ) )->parseAsBlock()
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
$out->addHtml(
|
||||||
|
$this->msg( 'gadgetusage-intro-noactive' )->parseAsBlock()
|
||||||
|
);
|
||||||
|
}
|
||||||
if ( $num > 0 ) {
|
if ( $num > 0 ) {
|
||||||
$this->outputTableStart();
|
$this->outputTableStart();
|
||||||
// Append default gadgets to the table with 'default' in the total and active user fields
|
// Append default gadgets to the table with 'default' in the total and active user fields
|
||||||
|
@ -164,7 +201,9 @@ class SpecialGadgetUsage extends QueryPage {
|
||||||
$html = Html::openElement( 'tr', array() );
|
$html = Html::openElement( 'tr', array() );
|
||||||
$html .= Html::element( 'td', array(), $default );
|
$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::element( 'td', array(), $this->msg( 'gadgetusage-default' ) );
|
||||||
|
}
|
||||||
$html .= Html::closeElement( 'tr' );
|
$html .= Html::closeElement( 'tr' );
|
||||||
$out->addHTML( $html );
|
$out->addHTML( $html );
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,7 +111,8 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
"GadgetsRepoClass": "MediaWikiGadgetsDefinitionRepo"
|
"GadgetsRepoClass": "MediaWikiGadgetsDefinitionRepo",
|
||||||
|
"SpecialGadgetUsageActiveUsers": true
|
||||||
},
|
},
|
||||||
"manifest_version": 1
|
"manifest_version": 1
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
"gadgetusage-usercount": "Number of users",
|
"gadgetusage-usercount": "Number of users",
|
||||||
"gadgetusage-noresults": "No gadgets found.",
|
"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": "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-activeusers": "Active users",
|
||||||
"gadgetusage-default": "Default",
|
"gadgetusage-default": "Default",
|
||||||
"gadgets-definition": "",
|
"gadgets-definition": "",
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
"gadgetusage-usercount": "Table column header on [[Special:GadgetUsage]]",
|
"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-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": "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-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",
|
"gadgetusage-default": "Message to indicate the gadget is default and actual stats are not available",
|
||||||
"gadgets-definition": "{{notranslate}}",
|
"gadgets-definition": "{{notranslate}}",
|
||||||
|
|
Loading…
Reference in a new issue