Compare commits
46 commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
384fdfa2bf | ||
![]() |
7f40072416 | ||
![]() |
e00a3b1c57 | ||
![]() |
95976e0082 | ||
![]() |
00af3f2598 | ||
![]() |
2b415b36b5 | ||
![]() |
1cf9ae8247 | ||
![]() |
548a1f177c | ||
![]() |
645c945994 | ||
![]() |
4212d24b49 | ||
![]() |
7d145662fa | ||
![]() |
7cc5575eaa | ||
![]() |
945f54a773 | ||
![]() |
d4dae78b27 | ||
![]() |
e307850555 | ||
![]() |
790e23f9bb | ||
![]() |
7fa71f5e78 | ||
![]() |
6666f47f3b | ||
![]() |
46ebf43828 | ||
![]() |
c68abe1641 | ||
![]() |
f9aa4a74b3 | ||
![]() |
d4132dab01 | ||
![]() |
228317e7c6 | ||
![]() |
c1d095e381 | ||
![]() |
120ae2bac0 | ||
![]() |
fb464fbd13 | ||
![]() |
6a8d6116e1 | ||
![]() |
35ea80cb36 | ||
![]() |
b7bf249857 | ||
![]() |
0a533b36f5 | ||
![]() |
5be2c8ed72 | ||
![]() |
71ace6a83c | ||
![]() |
6024bfd83b | ||
![]() |
5ade4bf529 | ||
![]() |
81fe64aea5 | ||
![]() |
32d5ef59fa | ||
![]() |
b0e2a7c59a | ||
![]() |
89e7ebc584 | ||
![]() |
908d2f68a2 | ||
![]() |
95800b51f3 | ||
![]() |
bb3429ecff | ||
![]() |
e5d96719d8 | ||
![]() |
fcb9c19544 | ||
![]() |
20f33b07f3 | ||
![]() |
309914b267 | ||
![]() |
571a707b3b |
10 changed files with 3261 additions and 1528 deletions
|
@ -1,16 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
if ( function_exists( 'wfLoadExtension' ) ) {
|
|
||||||
wfLoadExtension( 'ContributionScores' );
|
|
||||||
// Keep i18n globals so mergeMessageFileList.php doesn't break
|
|
||||||
$wgMessageDirs['ContributionScores'] = __DIR__ . '/i18n';
|
|
||||||
$wgExtensionMessagesFiles['ContributionScoresAlias'] = __DIR__ . '/ContributionScores.alias.php';
|
|
||||||
$wgExtensionMessagesFiles['ContributionScoresMagic'] = __DIR__ . '/ContributionScores.i18n.magic.php';
|
|
||||||
wfWarn(
|
|
||||||
'Deprecated PHP entry point used for ContributionScores extension. ' .
|
|
||||||
'Please use wfLoadExtension instead, ' .
|
|
||||||
'see https://www.mediawiki.org/wiki/Extension_registration for more details.'
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
die( 'This version of the ContributionScores extension requires MediaWiki 1.29+' );
|
|
||||||
}
|
|
|
@ -1,9 +1,9 @@
|
||||||
{
|
{
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"mediawiki/mediawiki-codesniffer": "38.0.0",
|
"mediawiki/mediawiki-codesniffer": "45.0.0",
|
||||||
"mediawiki/minus-x": "1.1.1",
|
"mediawiki/minus-x": "1.1.3",
|
||||||
"php-parallel-lint/php-console-highlighter": "0.5.0",
|
"php-parallel-lint/php-console-highlighter": "1.0.0",
|
||||||
"php-parallel-lint/php-parallel-lint": "1.2.0"
|
"php-parallel-lint/php-parallel-lint": "1.4.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"fix": [
|
"fix": [
|
||||||
|
@ -16,5 +16,10 @@
|
||||||
"minus-x check ."
|
"minus-x check ."
|
||||||
],
|
],
|
||||||
"phpcs": "phpcs -sp --cache"
|
"phpcs": "phpcs -sp --cache"
|
||||||
|
},
|
||||||
|
"config": {
|
||||||
|
"allow-plugins": {
|
||||||
|
"dealerdirect/phpcodesniffer-composer-installer": true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,10 +3,10 @@
|
||||||
"author": "Tim Laqua",
|
"author": "Tim Laqua",
|
||||||
"url": "https://www.mediawiki.org/wiki/Extension:Contribution_Scores",
|
"url": "https://www.mediawiki.org/wiki/Extension:Contribution_Scores",
|
||||||
"descriptionmsg": "contributionscores-desc",
|
"descriptionmsg": "contributionscores-desc",
|
||||||
"version": "1.26.0",
|
"version": "1.26.1",
|
||||||
"type": "specialpage",
|
"type": "specialpage",
|
||||||
"requires": {
|
"requires": {
|
||||||
"MediaWiki": ">= 1.33.0"
|
"MediaWiki": ">= 1.34.0"
|
||||||
},
|
},
|
||||||
"SpecialPages": {
|
"SpecialPages": {
|
||||||
"ContributionScores": "ContributionScores"
|
"ContributionScores": "ContributionScores"
|
||||||
|
@ -39,6 +39,10 @@
|
||||||
"value": false,
|
"value": false,
|
||||||
"description": "Set to true to exclude bots users from the reporting."
|
"description": "Set to true to exclude bots users from the reporting."
|
||||||
},
|
},
|
||||||
|
"ContribScoreIgnoreUsernames": {
|
||||||
|
"value": [],
|
||||||
|
"description": "Array of usernames to exclude from the reporting."
|
||||||
|
},
|
||||||
"ContribScoresUseRealName": {
|
"ContribScoresUseRealName": {
|
||||||
"value": false,
|
"value": false,
|
||||||
"description": "Set to true to use real user names when available."
|
"description": "Set to true to use real user names when available."
|
||||||
|
@ -46,6 +50,14 @@
|
||||||
"ContribScoreDisableCache": {
|
"ContribScoreDisableCache": {
|
||||||
"value": false,
|
"value": false,
|
||||||
"description": "Set to true to disable cache for parser function and inclusion of table."
|
"description": "Set to true to disable cache for parser function and inclusion of table."
|
||||||
|
},
|
||||||
|
"ContribScoreUseRoughEditCount": {
|
||||||
|
"value": false,
|
||||||
|
"description": "Set to true to use the rough number of edits in user table, for performance issue."
|
||||||
|
},
|
||||||
|
"ContribScoreCacheTTL": {
|
||||||
|
"value": 30,
|
||||||
|
"description": "Cache the contribution scores data, in minutes."
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"manifest_version": 2
|
"manifest_version": 2
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
{
|
|
||||||
"@metadata": {
|
|
||||||
"authors": [
|
|
||||||
"Better"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"contributionscores-days": "Úrtimus $1 dias"
|
|
||||||
}
|
|
|
@ -6,11 +6,12 @@
|
||||||
},
|
},
|
||||||
"contributionscores": "Contes de contribution",
|
"contributionscores": "Contes de contribution",
|
||||||
"contributionscores-desc": "Calcula li funde de data del wiki por max alt [[Special:ContributionScores|volúmine de contribution de usator]]",
|
"contributionscores-desc": "Calcula li funde de data del wiki por max alt [[Special:ContributionScores|volúmine de contribution de usator]]",
|
||||||
"contributionscores-info": "Contes es calculat quam seque:\n*Un (1) punctu por chascun págine unic redactet\n*Fonte de quadrat de (total de redactiones fat) - (total unique pages) * 2\nContes calculat in ti diversitá de redaction in pesa maniere súper de volúmine de redaction.\nBasicmen, ti conte mesura primarimen págines unic redactet, che consideration por alt volúmine de redaction - suposit esser un págine de alt qualitá.",
|
"contributionscores-info": "Li calcul primarimen mesura págines unic redactet, considerant li alt volume de redactiones.",
|
||||||
"contributionscores-top": "(Prim $1)",
|
"contributionscores-top": "(Prim $1)",
|
||||||
"contributionscores-days": "Ultim {{PLURAL:$1|die|$1 dies}}",
|
"contributionscores-days": "Ultim {{PLURAL:$1|die|$1 dies}}",
|
||||||
"contributionscores-allrevisions": "Omni témpor",
|
"contributionscores-allrevisions": "Omni témpor",
|
||||||
"contributionscores-score": "Conte",
|
"contributionscores-score": "Conte",
|
||||||
|
"contributionscores-rank": "Classification",
|
||||||
"contributionscores-pages": "Págines",
|
"contributionscores-pages": "Págines",
|
||||||
"contributionscores-changes": "Changes",
|
"contributionscores-changes": "Changes",
|
||||||
"contributionscores-username": "Nómine de usator",
|
"contributionscores-username": "Nómine de usator",
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"contributionscores-days": "Lasta {{PLURAL:$1|dio|$1 dii}}",
|
"contributionscores-days": "Lasta {{PLURAL:$1|dio|$1 dii}}",
|
||||||
|
"contributionscores-score": "Nombro di punti",
|
||||||
"contributionscores-pages": "Pagini",
|
"contributionscores-pages": "Pagini",
|
||||||
|
"contributionscores-changes": "Modifikuri",
|
||||||
"contributionscores-username": "Uzeronomo"
|
"contributionscores-username": "Uzeronomo"
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,5 +6,5 @@
|
||||||
},
|
},
|
||||||
"contributionscores-pages": "ገጻት",
|
"contributionscores-pages": "ገጻት",
|
||||||
"contributionscores-changes": "ለውጥታት",
|
"contributionscores-changes": "ለውጥታት",
|
||||||
"contributionscores-username": "ሽም ተጠቃሚ"
|
"contributionscores-username": "ስም ተጠቃሚ"
|
||||||
}
|
}
|
||||||
|
|
4576
package-lock.json
generated
4576
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -5,9 +5,9 @@
|
||||||
"test": "grunt test"
|
"test": "grunt test"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"eslint-config-wikimedia": "0.19.0",
|
"eslint-config-wikimedia": "0.28.2",
|
||||||
"grunt": "1.5.3",
|
"grunt": "1.6.1",
|
||||||
"grunt-banana-checker": "0.9.0",
|
"grunt-banana-checker": "0.13.0",
|
||||||
"grunt-eslint": "23.0.0"
|
"grunt-eslint": "24.3.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,51 +26,50 @@ class ContributionScores extends IncludableSpecialPage {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function efContributionScoresRender( $parser, $usertext, $metric = 'score' ) {
|
public static function efContributionScoresRender( $parser, $usertext, $metric = 'score' ) {
|
||||||
global $wgContribScoreDisableCache;
|
global $wgContribScoreDisableCache, $wgContribScoreUseRoughEditCount;
|
||||||
|
|
||||||
if ( $wgContribScoreDisableCache ) {
|
if ( $wgContribScoreDisableCache ) {
|
||||||
$parser->getOutput()->updateCacheExpiry( 0 );
|
$parser->getOutput()->updateCacheExpiry( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = User::newFromName( $usertext );
|
$user = User::newFromName( $usertext );
|
||||||
$dbr = wfGetDB( DB_REPLICA );
|
$loadBalancer = MediaWikiServices::getInstance()->getDBLoadBalancer();
|
||||||
|
$dbr = $loadBalancer->getConnection( DB_REPLICA );
|
||||||
|
|
||||||
if ( $user instanceof User && $user->isLoggedIn() ) {
|
if ( $user instanceof User && $user->isRegistered() ) {
|
||||||
global $wgLang;
|
global $wgLang;
|
||||||
|
$revVar = $wgContribScoreUseRoughEditCount ? 'user_editcount' : 'COUNT(rev_id)';
|
||||||
|
|
||||||
$revWhere = ActorMigration::newMigration()->getWhere( $dbr, 'rev_user', $user );
|
$revWhere = ActorMigration::newMigration()->getWhere( $dbr, 'rev_user', $user );
|
||||||
if ( $metric == 'score' ) {
|
if ( $metric == 'score' ) {
|
||||||
$res = $dbr->select(
|
$row = $dbr->selectRow(
|
||||||
[ 'revision' ] + $revWhere['tables'],
|
[ 'revision' ] + $revWhere['tables'],
|
||||||
'COUNT(DISTINCT rev_page)+SQRT(COUNT(rev_id)-COUNT(DISTINCT rev_page))*2 AS wiki_rank',
|
[ 'wiki_rank' => "COUNT(DISTINCT rev_page)+SQRT($revVar-COUNT(DISTINCT rev_page))*2" ],
|
||||||
$revWhere['conds'],
|
$revWhere['conds'],
|
||||||
__METHOD__,
|
__METHOD__,
|
||||||
[],
|
[],
|
||||||
$revWhere['joins']
|
$revWhere['joins']
|
||||||
);
|
);
|
||||||
$row = $dbr->fetchObject( $res );
|
|
||||||
$output = $wgLang->formatNum( round( $row->wiki_rank, 0 ) );
|
$output = $wgLang->formatNum( round( $row->wiki_rank, 0 ) );
|
||||||
} elseif ( $metric == 'changes' ) {
|
} elseif ( $metric == 'changes' ) {
|
||||||
$res = $dbr->select(
|
$row = $dbr->selectRow(
|
||||||
[ 'revision' ] + $revWhere['tables'],
|
[ 'revision' ] + $revWhere['tables'],
|
||||||
'COUNT(rev_id) AS rev_count',
|
[ 'rev_count' => $revVar ],
|
||||||
$revWhere['conds'],
|
$revWhere['conds'],
|
||||||
__METHOD__,
|
__METHOD__,
|
||||||
[],
|
[],
|
||||||
$revWhere['joins']
|
$revWhere['joins']
|
||||||
);
|
);
|
||||||
$row = $dbr->fetchObject( $res );
|
|
||||||
$output = $wgLang->formatNum( $row->rev_count );
|
$output = $wgLang->formatNum( $row->rev_count );
|
||||||
} elseif ( $metric == 'pages' ) {
|
} elseif ( $metric == 'pages' ) {
|
||||||
$res = $dbr->select(
|
$row = $dbr->selectRow(
|
||||||
[ 'revision' ] + $revWhere['tables'],
|
[ 'revision' ] + $revWhere['tables'],
|
||||||
'COUNT(DISTINCT rev_page) AS page_count',
|
[ 'page_count' => 'COUNT(DISTINCT rev_page)' ],
|
||||||
$revWhere['conds'],
|
$revWhere['conds'],
|
||||||
__METHOD__,
|
__METHOD__,
|
||||||
[],
|
[],
|
||||||
$revWhere['joins']
|
$revWhere['joins']
|
||||||
);
|
);
|
||||||
$row = $dbr->fetchObject( $res );
|
|
||||||
$output = $wgLang->formatNum( $row->page_count );
|
$output = $wgLang->formatNum( $row->page_count );
|
||||||
} else {
|
} else {
|
||||||
$output = wfMessage( 'contributionscores-invalidmetric' )->text();
|
$output = wfMessage( 'contributionscores-invalidmetric' )->text();
|
||||||
|
@ -78,45 +77,65 @@ class ContributionScores extends IncludableSpecialPage {
|
||||||
} else {
|
} else {
|
||||||
$output = wfMessage( 'contributionscores-invalidusername' )->text();
|
$output = wfMessage( 'contributionscores-invalidusername' )->text();
|
||||||
}
|
}
|
||||||
return $parser->insertStripItem( $output, $parser->mStripState );
|
return $parser->insertStripItem( $output, $parser->getStripState() );
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Generates a "Contribution Scores" table for a given LIMIT and date range
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function generates Contribution Scores tables in HTML format (not wikiText)
|
* Function fetch Contribution Scores data from database
|
||||||
*
|
*
|
||||||
* @param int $days Days in the past to run report for
|
* @param int $days Days in the past to run report for
|
||||||
* @param int $limit Maximum number of users to return (default 50)
|
* @param int $limit Maximum number of users to return (default 50)
|
||||||
* @param string|null $title The title of the table
|
* @return array Data including the requested Contribution Scores.
|
||||||
* @param array $options array of options (default none; nosort/notools)
|
|
||||||
* @return string Html Table representing the requested Contribution Scores.
|
|
||||||
*/
|
*/
|
||||||
function genContributionScoreTable( $days, $limit, $title = null, $options = 'none' ) {
|
public static function getContributionScoreData( $days, $limit ) {
|
||||||
global $wgContribScoreIgnoreBots, $wgContribScoreIgnoreBlockedUsers, $wgContribScoresUseRealName;
|
global $wgContribScoreIgnoreBots, $wgContribScoreIgnoreBlockedUsers, $wgContribScoreIgnoreUsernames,
|
||||||
|
$wgContribScoreUseRoughEditCount;
|
||||||
|
|
||||||
$opts = explode( ',', strtolower( $options ) );
|
$loadBalancer = MediaWikiServices::getInstance()->getDBLoadBalancer();
|
||||||
|
$dbr = $loadBalancer->getConnection( DB_REPLICA );
|
||||||
|
|
||||||
$dbr = wfGetDB( DB_REPLICA );
|
$revQuery = ActorMigration::newMigration()->getJoin( 'rev_user' );
|
||||||
|
$revQuery['tables'] = array_merge( [ 'revision' ], $revQuery['tables'] );
|
||||||
$store = MediaWikiServices::getInstance()
|
|
||||||
->getRevisionStoreFactory()
|
|
||||||
->getRevisionStore();
|
|
||||||
$revQuery = $store->getQueryInfo();
|
|
||||||
|
|
||||||
$revUser = $revQuery['fields']['rev_user'];
|
$revUser = $revQuery['fields']['rev_user'];
|
||||||
|
$revUsername = $revQuery['fields']['rev_user_text'];
|
||||||
|
|
||||||
$sqlWhere = [];
|
$sqlWhere = [];
|
||||||
|
|
||||||
if ( $days > 0 ) {
|
if ( $days > 0 ) {
|
||||||
$date = time() - ( 60 * 60 * 24 * $days );
|
$date = time() - ( 60 * 60 * 24 * $days );
|
||||||
$dateString = $dbr->timestamp( $date );
|
$sqlWhere[] = 'rev_timestamp > ' . $dbr->addQuotes( $dbr->timestamp( $date ) );
|
||||||
$sqlWhere[] = "rev_timestamp > '$dateString'";
|
}
|
||||||
|
|
||||||
|
$sqlVars = [
|
||||||
|
'rev_user' => $revUser,
|
||||||
|
'page_count' => 'COUNT(DISTINCT rev_page)'
|
||||||
|
];
|
||||||
|
if ( $wgContribScoreUseRoughEditCount ) {
|
||||||
|
$revQuery['tables'][] = 'user';
|
||||||
|
$revQuery['joins']['user'] = [ 'LEFT JOIN', [ "$revUser != 0", "user_id = $revUser" ] ];
|
||||||
|
$sqlVars['rev_count'] = 'user_editcount';
|
||||||
|
} else {
|
||||||
|
$sqlVars['rev_count'] = 'COUNT(rev_id)';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $wgContribScoreIgnoreBlockedUsers ) {
|
if ( $wgContribScoreIgnoreBlockedUsers ) {
|
||||||
$sqlWhere[] = "{$revUser} NOT IN " .
|
$sqlWhere[] = "{$revUser} NOT IN " .
|
||||||
$dbr->buildSelectSubquery( 'ipblocks', 'ipb_user', 'ipb_user <> 0', __METHOD__ );
|
$dbr->buildSelectSubquery( [
|
||||||
|
'block',
|
||||||
|
'block_target'
|
||||||
|
],
|
||||||
|
'bt_user',
|
||||||
|
'bt_user <> 0',
|
||||||
|
__METHOD__,
|
||||||
|
[],
|
||||||
|
[
|
||||||
|
'block_target' => [ 'JOIN', [
|
||||||
|
'bl_target=bt_id'
|
||||||
|
] ]
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $wgContribScoreIgnoreBots ) {
|
if ( $wgContribScoreIgnoreBots ) {
|
||||||
|
@ -127,23 +146,24 @@ class ContributionScores extends IncludableSpecialPage {
|
||||||
], __METHOD__ );
|
], __METHOD__ );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( count( $wgContribScoreIgnoreUsernames ) ) {
|
||||||
|
$listIgnoredUsernames = $dbr->makeList( $wgContribScoreIgnoreUsernames );
|
||||||
|
$sqlWhere[] = "{$revUsername} NOT IN ($listIgnoredUsernames)";
|
||||||
|
}
|
||||||
|
|
||||||
if ( $dbr->unionSupportsOrderAndLimit() ) {
|
if ( $dbr->unionSupportsOrderAndLimit() ) {
|
||||||
$order = [
|
$order = [
|
||||||
'GROUP BY' => $revUser,
|
'GROUP BY' => 'rev_user',
|
||||||
'ORDER BY' => 'page_count DESC',
|
'ORDER BY' => 'page_count DESC',
|
||||||
'LIMIT' => $limit
|
'LIMIT' => $limit
|
||||||
];
|
];
|
||||||
} else {
|
} else {
|
||||||
$order = [ 'GROUP BY' => $revUser ];
|
$order = [ 'GROUP BY' => 'rev_user' ];
|
||||||
}
|
}
|
||||||
|
|
||||||
$sqlMostPages = $dbr->selectSQLText(
|
$sqlMostPages = $dbr->selectSQLText(
|
||||||
$revQuery['tables'],
|
$revQuery['tables'],
|
||||||
[
|
$sqlVars,
|
||||||
'rev_user' => $revUser,
|
|
||||||
'page_count' => 'COUNT(DISTINCT rev_page)',
|
|
||||||
'rev_count' => 'COUNT(rev_id)',
|
|
||||||
],
|
|
||||||
$sqlWhere,
|
$sqlWhere,
|
||||||
__METHOD__,
|
__METHOD__,
|
||||||
$order,
|
$order,
|
||||||
|
@ -151,22 +171,12 @@ class ContributionScores extends IncludableSpecialPage {
|
||||||
);
|
);
|
||||||
|
|
||||||
if ( $dbr->unionSupportsOrderAndLimit() ) {
|
if ( $dbr->unionSupportsOrderAndLimit() ) {
|
||||||
$order = [
|
$order['ORDER BY'] = 'rev_count DESC';
|
||||||
'GROUP BY' => 'rev_user',
|
|
||||||
'ORDER BY' => 'rev_count DESC',
|
|
||||||
'LIMIT' => $limit
|
|
||||||
];
|
|
||||||
} else {
|
|
||||||
$order = [ 'GROUP BY' => 'rev_user' ];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$sqlMostRevs = $dbr->selectSQLText(
|
$sqlMostRevs = $dbr->selectSQLText(
|
||||||
$revQuery['tables'],
|
$revQuery['tables'],
|
||||||
[
|
$sqlVars,
|
||||||
'rev_user' => $revUser,
|
|
||||||
'page_count' => 'COUNT(DISTINCT rev_page)',
|
|
||||||
'rev_count' => 'COUNT(rev_id)',
|
|
||||||
],
|
|
||||||
$sqlWhere,
|
$sqlWhere,
|
||||||
__METHOD__,
|
__METHOD__,
|
||||||
$order,
|
$order,
|
||||||
|
@ -191,7 +201,6 @@ class ContributionScores extends IncludableSpecialPage {
|
||||||
__METHOD__,
|
__METHOD__,
|
||||||
[
|
[
|
||||||
'ORDER BY' => 'wiki_rank DESC',
|
'ORDER BY' => 'wiki_rank DESC',
|
||||||
'GROUP BY' => 'user_name',
|
|
||||||
'LIMIT' => $limit,
|
'LIMIT' => $limit,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
@ -201,6 +210,25 @@ class ContributionScores extends IncludableSpecialPage {
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
$ret = iterator_to_array( $res );
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Generates a "Contribution Scores" table for a given LIMIT and date range
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function generates Contribution Scores tables in HTML format (not wikiText)
|
||||||
|
*
|
||||||
|
* @param int $days Days in the past to run report for
|
||||||
|
* @param int $limit Maximum number of users to return (default 50)
|
||||||
|
* @param string|null $title The title of the table
|
||||||
|
* @param array $options array of options (default none; nosort/notools)
|
||||||
|
* @return string Html Table representing the requested Contribution Scores.
|
||||||
|
*/
|
||||||
|
function genContributionScoreTable( $days, $limit, $title = null, $options = 'none' ) {
|
||||||
|
global $wgContribScoresUseRealName, $wgContribScoreCacheTTL;
|
||||||
|
|
||||||
|
$opts = explode( ',', strtolower( $options ) );
|
||||||
|
|
||||||
$sortable = in_array( 'nosort', $opts ) ? '' : ' sortable';
|
$sortable = in_array( 'nosort', $opts ) ? '' : ' sortable';
|
||||||
|
|
||||||
|
@ -212,11 +240,26 @@ class ContributionScores extends IncludableSpecialPage {
|
||||||
Html::element( 'th', [], $this->msg( 'contributionscores-changes' )->text() ) .
|
Html::element( 'th', [], $this->msg( 'contributionscores-changes' )->text() ) .
|
||||||
Html::element( 'th', [], $this->msg( 'contributionscores-username' )->text() );
|
Html::element( 'th', [], $this->msg( 'contributionscores-username' )->text() );
|
||||||
|
|
||||||
|
$cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
|
||||||
|
$data = $cache->getWithSetCallback(
|
||||||
|
$cache->makeKey( 'contributionscores', 'data-' . (string)$days ),
|
||||||
|
$wgContribScoreCacheTTL * 60,
|
||||||
|
function () use ( $days ) {
|
||||||
|
// Use max limit, as limit doesn't matter with performance.
|
||||||
|
// Avoid purge multiple times since limit on transclusion can be vary.
|
||||||
|
return self::getContributionScoreData( $days, self::CONTRIBUTIONSCORES_MAXINCLUDELIMIT );
|
||||||
|
} );
|
||||||
|
|
||||||
|
$lang = $this->getLanguage();
|
||||||
|
|
||||||
$altrow = '';
|
$altrow = '';
|
||||||
$user_rank = 1;
|
$user_rank = 1;
|
||||||
|
|
||||||
$lang = $this->getLanguage();
|
foreach ( $data as $row ) {
|
||||||
foreach ( $res as $row ) {
|
if ( $user_rank > $limit ) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// Use real name if option used and real name present.
|
// Use real name if option used and real name present.
|
||||||
if ( $wgContribScoresUseRealName && $row->user_real_name !== '' ) {
|
if ( $wgContribScoresUseRealName && $row->user_real_name !== '' ) {
|
||||||
$userLink = Linker::userLink(
|
$userLink = Linker::userLink(
|
||||||
|
@ -234,7 +277,7 @@ class ContributionScores extends IncludableSpecialPage {
|
||||||
$output .= Html::closeElement( 'tr' );
|
$output .= Html::closeElement( 'tr' );
|
||||||
$output .= "<tr class='{$altrow}'>\n" .
|
$output .= "<tr class='{$altrow}'>\n" .
|
||||||
"<td class='content' style='padding-right:10px;text-align:right;'>" .
|
"<td class='content' style='padding-right:10px;text-align:right;'>" .
|
||||||
$lang->formatNum( round( $user_rank, 0 ) ) .
|
$lang->formatNum( $user_rank ) .
|
||||||
"\n</td><td class='content' style='padding-right:10px;text-align:right;'>" .
|
"\n</td><td class='content' style='padding-right:10px;text-align:right;'>" .
|
||||||
$lang->formatNum( round( $row->wiki_rank, 0 ) ) .
|
$lang->formatNum( round( $row->wiki_rank, 0 ) ) .
|
||||||
"\n</td><td class='content' style='padding-right:10px;text-align:right;'>" .
|
"\n</td><td class='content' style='padding-right:10px;text-align:right;'>" .
|
||||||
|
@ -262,8 +305,7 @@ class ContributionScores extends IncludableSpecialPage {
|
||||||
$output .= Html::closeElement( 'tr' );
|
$output .= Html::closeElement( 'tr' );
|
||||||
$output .= Html::closeElement( 'table' );
|
$output .= Html::closeElement( 'table' );
|
||||||
|
|
||||||
$dbr->freeResult( $res );
|
// Transcluded on a normal wiki page.
|
||||||
|
|
||||||
if ( !empty( $title ) ) {
|
if ( !empty( $title ) ) {
|
||||||
$output = Html::rawElement( 'table',
|
$output = Html::rawElement( 'table',
|
||||||
[
|
[
|
||||||
|
@ -364,7 +406,7 @@ class ContributionScores extends IncludableSpecialPage {
|
||||||
$out->addWikiMsg( 'contributionscores-info' );
|
$out->addWikiMsg( 'contributionscores-info' );
|
||||||
|
|
||||||
foreach ( $wgContribScoreReports as $scoreReport ) {
|
foreach ( $wgContribScoreReports as $scoreReport ) {
|
||||||
list( $days, $revs ) = $scoreReport;
|
[ $days, $revs ] = $scoreReport;
|
||||||
if ( $days > 0 ) {
|
if ( $days > 0 ) {
|
||||||
$reportTitle = $this->msg( 'contributionscores-days' )->numParams( $days )->text();
|
$reportTitle = $this->msg( 'contributionscores-days' )->numParams( $days )->text();
|
||||||
} else {
|
} else {
|
||||||
|
@ -380,6 +422,11 @@ class ContributionScores extends IncludableSpecialPage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function maxIncludeCacheTime() {
|
||||||
|
global $wgContribScoreDisableCache, $wgContribScoreCacheTTL;
|
||||||
|
return $wgContribScoreDisableCache ? 0 : $wgContribScoreCacheTTL;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Reference in a new issue