/*
* This script allows to count the number of times a steward has used CheckUser on a wiki.
* It was written in response in to [[Talk:Stewards/CheckUser_statistics_for_loginwiki#Update_required]]
* but can be used for other wikis too.
*
* To run the script, change the month as needed (see queryCheckUserLog() function) and run
* it on your browser console on Special:BlankPage.
*
* Caveats:
* - Only current stewards are counted. Previous stewards' stats have to be counted manually.
* - It assumes that the no. of CUs per steward is maximum 4000 (can be easily changed if needed).
* - It assumes that the max no. of stewards is 150 (also changeable)
*/
var api = new mw.Api();
function getStewards() {
return api.get( {
format: 'json',
action: 'query',
list: 'globalallusers',
agugroup: 'steward',
agulimit: 150 // We probably won't have stewards more than this anytime soon
} );
}
function queryCheckUserLog( username ) {
return api.get( {
format: 'json',
list: 'checkuserlog',
culuser: username,
cullimit: 4000, // eh.. hopefully no one does more than this in a month
culdir: 'newer',
// Please don't change the format unless you know what you're doing or it might break
culfrom: new Date( '1 January 2016 UTC' ).toISOString(), // Start date
culto: new Date( '1 February 2016 UTC' ).toISOString() // End date
} );
}
function appendToPage( text ) {
// Note: text must be trusted!
$( '#mw-content-text' ).append( text + '
' );
}
function getStatsTable( entries ) {
var html =
'
Username | ' + 'Count | ' + '
---|---|
' + mw.html.escape( entry.name ) + ' | ' + '' + mw.html.escape( entry.count ) + ' | ' + '