Merge "Introduce a config, to use the rough number of edits in user table"
This commit is contained in:
commit
b7bf249857
2 changed files with 25 additions and 15 deletions
|
@ -46,6 +46,10 @@
|
||||||
"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."
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"manifest_version": 2
|
"manifest_version": 2
|
||||||
|
|
|
@ -24,7 +24,7 @@ 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 );
|
||||||
|
@ -35,12 +35,13 @@ class ContributionScores extends IncludableSpecialPage {
|
||||||
|
|
||||||
if ( $user instanceof User && $user->isRegistered() ) {
|
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(
|
$res = $dbr->select(
|
||||||
[ '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__,
|
||||||
[],
|
[],
|
||||||
|
@ -51,7 +52,7 @@ class ContributionScores extends IncludableSpecialPage {
|
||||||
} elseif ( $metric == 'changes' ) {
|
} elseif ( $metric == 'changes' ) {
|
||||||
$res = $dbr->select(
|
$res = $dbr->select(
|
||||||
[ 'revision' ] + $revWhere['tables'],
|
[ 'revision' ] + $revWhere['tables'],
|
||||||
'COUNT(rev_id) AS rev_count',
|
[ 'rev_count' => $revVar ],
|
||||||
$revWhere['conds'],
|
$revWhere['conds'],
|
||||||
__METHOD__,
|
__METHOD__,
|
||||||
[],
|
[],
|
||||||
|
@ -62,7 +63,7 @@ class ContributionScores extends IncludableSpecialPage {
|
||||||
} elseif ( $metric == 'pages' ) {
|
} elseif ( $metric == 'pages' ) {
|
||||||
$res = $dbr->select(
|
$res = $dbr->select(
|
||||||
[ '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__,
|
||||||
[],
|
[],
|
||||||
|
@ -91,7 +92,8 @@ class ContributionScores extends IncludableSpecialPage {
|
||||||
* @return string Html Table representing the requested Contribution Scores.
|
* @return string Html Table representing the requested Contribution Scores.
|
||||||
*/
|
*/
|
||||||
function genContributionScoreTable( $days, $limit, $title = null, $options = 'none' ) {
|
function genContributionScoreTable( $days, $limit, $title = null, $options = 'none' ) {
|
||||||
global $wgContribScoreIgnoreBots, $wgContribScoreIgnoreBlockedUsers, $wgContribScoresUseRealName;
|
global $wgContribScoreIgnoreBots, $wgContribScoreIgnoreBlockedUsers, $wgContribScoresUseRealName,
|
||||||
|
$wgContribScoreUseRoughEditCount;
|
||||||
|
|
||||||
$opts = explode( ',', strtolower( $options ) );
|
$opts = explode( ',', strtolower( $options ) );
|
||||||
|
|
||||||
|
@ -109,6 +111,18 @@ class ContributionScores extends IncludableSpecialPage {
|
||||||
$sqlWhere[] = 'rev_timestamp > ' . $dbr->addQuotes( $dbr->timestamp( $date ) );
|
$sqlWhere[] = 'rev_timestamp > ' . $dbr->addQuotes( $dbr->timestamp( $date ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$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( 'ipblocks', 'ipb_user', 'ipb_user <> 0', __METHOD__ );
|
||||||
|
@ -134,11 +148,7 @@ class ContributionScores extends IncludableSpecialPage {
|
||||||
|
|
||||||
$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,11 +161,7 @@ class ContributionScores extends IncludableSpecialPage {
|
||||||
|
|
||||||
$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,
|
||||||
|
|
Loading…
Add table
Reference in a new issue