Add tests
Fix all issues so tests pass. Change-Id: I8a059c26d16944d4ddfb56959617fb73887e7b6a
This commit is contained in:
parent
8f657f7205
commit
e4cb919476
10 changed files with 146 additions and 95 deletions
|
@ -1,11 +1,11 @@
|
|||
<?php
|
||||
/** \file
|
||||
* \brief Contains setup code for the Contribution Scores Extension.
|
||||
*/
|
||||
* \brief Contains setup code for the Contribution Scores Extension.
|
||||
*/
|
||||
|
||||
# Not a valid entry point, skip unless MEDIAWIKI is defined
|
||||
if ( !defined( 'MEDIAWIKI' ) ) {
|
||||
echo "Contribution Scores extension";
|
||||
echo 'Contribution Scores extension';
|
||||
exit( 1 );
|
||||
}
|
||||
|
||||
|
@ -15,32 +15,39 @@ $wgExtensionCredits['specialpage'][] = array(
|
|||
'url' => 'https://www.mediawiki.org/wiki/Extension:Contribution_Scores',
|
||||
'author' => 'Tim Laqua',
|
||||
'descriptionmsg' => 'contributionscores-desc',
|
||||
'version' => '1.17.0'
|
||||
'version' => '1.23.0'
|
||||
);
|
||||
|
||||
$dir = dirname( __FILE__ ) . '/';
|
||||
|
||||
define( 'CONTRIBUTIONSCORES_MAXINCLUDELIMIT', 50 );
|
||||
$wgContribScoreReports = null;
|
||||
|
||||
// These settings can be overridden in LocalSettings.php.
|
||||
$wgContribScoreIgnoreBlockedUsers = false; // Set to true to exclude bots from the reporting.
|
||||
$wgContribScoreIgnoreBots = false; // Set to true to exclude blocked users from the reporting.
|
||||
$wgContribScoresUseRealName = false; // Set to true to use real user names when available. Only for MediaWiki 1.19 and later.
|
||||
$wgContribScoreDisableCache = false; // Set to true to disable cache for parser function and inclusion of table.
|
||||
|
||||
$wgAutoloadClasses['ContributionScores'] = $dir . 'ContributionScores_body.php';
|
||||
// Set to true to exclude bots from the reporting.
|
||||
$wgContribScoreIgnoreBlockedUsers = false;
|
||||
|
||||
// Set to true to exclude blocked users from the reporting.
|
||||
$wgContribScoreIgnoreBots = false;
|
||||
|
||||
// Set to true to use real user names when available. Only for MediaWiki 1.19 and later.
|
||||
$wgContribScoresUseRealName = false;
|
||||
|
||||
// Set to true to disable cache for parser function and inclusion of table.
|
||||
$wgContribScoreDisableCache = false;
|
||||
|
||||
$wgAutoloadClasses['ContributionScores'] = __DIR__ . '/ContributionScores_body.php';
|
||||
$wgSpecialPages['ContributionScores'] = 'ContributionScores';
|
||||
|
||||
$wgMessagesDirs['ContributionScores'] = __DIR__ . '/i18n';
|
||||
$wgExtensionMessagesFiles['ContributionScores'] = $dir . 'ContributionScores.i18n.php';
|
||||
$wgExtensionMessagesFiles['ContributionScoresAlias'] = $dir . 'ContributionScores.alias.php';
|
||||
$wgExtensionMessagesFiles['ContributionScoresMagic'] = $dir . 'ContributionScores.i18n.magic.php';
|
||||
$wgExtensionMessagesFiles['ContributionScoresAlias'] = __DIR__ . '/ContributionScores.alias.php';
|
||||
$wgExtensionMessagesFiles['ContributionScoresMagic'] =
|
||||
__DIR__ . '/ContributionScores.i18n.magic.php';
|
||||
|
||||
$wgHooks['ParserFirstCallInit'][] = 'efContributionScores_Setup';
|
||||
|
||||
function efContributionScores_Setup( &$parser ) {
|
||||
$parser->setFunctionHook( 'cscore', 'efContributionScores_Render' );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -59,21 +66,20 @@ function efContributionScores_Render( &$parser, $usertext, $metric = 'score' ) {
|
|||
|
||||
if ( $metric == 'score' ) {
|
||||
$res = $dbr->select( 'revision',
|
||||
'COUNT(DISTINCT rev_page)+SQRT(COUNT(rev_id)-COUNT(DISTINCT rev_page))*2 AS wiki_rank',
|
||||
array( 'rev_user' => $user->getID() ) );
|
||||
'COUNT(DISTINCT rev_page)+SQRT(COUNT(rev_id)-COUNT(DISTINCT rev_page))*2 AS wiki_rank',
|
||||
array( 'rev_user' => $user->getID() ) );
|
||||
$row = $dbr->fetchObject( $res );
|
||||
$output = $wgLang->formatNum( round( $row->wiki_rank, 0 ) );
|
||||
} elseif ( $metric == 'changes' ) {
|
||||
$res = $dbr->select( 'revision',
|
||||
'COUNT(rev_id) AS rev_count',
|
||||
array( 'rev_user' => $user->getID() ) );
|
||||
'COUNT(rev_id) AS rev_count',
|
||||
array( 'rev_user' => $user->getID() ) );
|
||||
$row = $dbr->fetchObject( $res );
|
||||
$output = $wgLang->formatNum( $row->rev_count );
|
||||
|
||||
} elseif ( $metric == 'pages' ) {
|
||||
$res = $dbr->select( 'revision',
|
||||
'COUNT(DISTINCT rev_page) AS page_count',
|
||||
array( 'rev_user' => $user->getID() ) );
|
||||
'COUNT(DISTINCT rev_page) AS page_count',
|
||||
array( 'rev_user' => $user->getID() ) );
|
||||
$row = $dbr->fetchObject( $res );
|
||||
$output = $wgLang->formatNum( $row->page_count );
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue