Page MenuHomeMiraheze
Paste P150

(An Untitled Masterwork)
ActivePublic

Authored by Paladox on Dec 4 2018, 22:21.
Tags
None
Referenced Files
F871761:
Dec 4 2018, 22:40
F871759:
Dec 4 2018, 22:38
F871758:
Dec 4 2018, 22:28
F871756:
Dec 4 2018, 22:21
Subscribers
None
/**
* 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 $wgContribScoreIgnoreBots, $wgContribScoreIgnoreBlockedUsers, $wgContribScoresUseRealName;
$opts = explode( ',', strtolower( $options ) );
$dbr = wfGetDB( DB_REPLICA );
$userTable = $dbr->tableName( 'user' );
$userGroupTable = $dbr->tableName( 'user_groups' );
$revTable = $dbr->tableName( 'revision' );
$ipBlocksTable = $dbr->tableName( 'ipblocks' );
$sqlWhere = [];
if ( $days > 0 ) {
$date = time() - ( 60 * 60 * 24 * $days );
$dateString = $dbr->timestamp( $date );
$sqlWhere[] = "rev_timestamp > '$dateString'";
}
if ( $wgContribScoreIgnoreBlockedUsers ) {
$sqlWhere[] = "rev_user NOT IN " .
"(SELECT ipb_user FROM {$ipBlocksTable} WHERE ipb_user <> 0)";
}
if ( $wgContribScoreIgnoreBots ) {
$sqlWhere[] = "rev_user NOT IN " .
"(SELECT ug_user FROM {$userGroupTable} WHERE ug_group='bot')";
}
$revQuery = Revision::getQueryInfo();
$sqlMostPages = $dbr->select(
$revQuery['tables'],
[
'rev_user' => $revQuery['fields']['rev_user'],
'page_count' => 'COUNT(DISTINCT rev_page)',
'rev_count' => 'COUNT(rev_id)',
],
$sqlWhere,
__METHOD__,
[
'GROUP BY' => 'rev_user',
'ORDER BY' => 'page_count DESC',
'LIMIT' => {$limit}
],
$revQuery['joins']
);