Jump to content

User:SQL/Admin CSS-JS Editing

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by SQL (talk | contribs) at 21:40, 5 August 2018 (Change from SQL to a php script, now running, ~2 hours out). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Source code
<?php
$query = "select user_name, user_id from user join user_groups on ug_user = user_id where ug_group = 'sysop';";

$ts_pw = posix_getpwuid(posix_getuid());
$ts_mycnf = parse_ini_file($ts_pw['dir'] . "/replica.my.cnf");

$mysqli = new mysqli('enwiki.analytics.db.svc.eqiad.wmflabs', $ts_mycnf['user'], $ts_mycnf['password'], 'enwiki_p');

$result = mysqli_query( $mysqli, $query );
$outtauserspace = array();
$overall = array();
$mwonly = array();
$rows = mysqli_num_rows( $result );
$times = array();
$on = 0;
while ( $row = mysqli_fetch_assoc( $result ) ) {
    $start = microtime( TRUE );
    $on++;
    $uid = $row['user_id'];
    $name = str_replace( " ", "_", $row['user_name'] );
    $outtauserspace[$name] = 0;
    $overall[$name] = 0;
    $mwonly[$name] = 0;
    $newQ = "select distinct page_title, page_namespace from   page   join revision_userindex on rev_page = page_id where (page_namespace = 2 OR page_namespace = 8) and  rev_user = '$uid';";
    $newR = mysqli_query( $mysqli, $newQ );
    while( $uRow = mysqli_fetch_assoc( $newR ) ) {
	$title = $uRow['page_title'];
	$namespace = $uRow['page_namespace'];
	if( preg_match( "/^.*\.(css|js)$/i", $title ) == 1 ) {
	    if( $namespace == 2 ) {
		//$title was in userspace
		$parts = explode( "/", $title );
		if( $parts[0] != $name ) {
		    $outtauserspace[$name]++;
		    $overall[$name]++;
		}
	    } elseif ( $namespace == 8 ) {
		$mwonly[$name]++;
		$overall[$name]++;
	    } else {
		$overall[$name]++;
	    }
	}
    }
    $finish = microtime( TRUE );
    $diff = round( $finish - $start, 4 );
    array_push( $times, $diff );
    $avg = round( array_sum( $times ) / count( $times ), 4 );
    $end = round( ( $rows - $on ) * $avg, 4 );;
    echo "[$on/$rows] - Last: $diff(s) Avg: $avg(s) - Expected end: $end(s) Current admin: $name\n";

}
arsort( $outtauserspace );
arsort( $overall );
arsort( $mwonly );

$stats = array();
$stats['zero'] = 0;
$stats['1to10'] = 0;
$stats['11to50'] = 0;
$stats['51to100'] = 0;
$stats['101to250'] = 0;
$stats['251to1000'] = 0;
$stats['1001to2500'] = 0;
$stats['2501plus'] = 0;
$table = "{| class='wikitable sortable'
|-
! Name
! Overall JS/CSS Edits
! MW JS/CSS Edits
! Userspace JS/CSS Edits
|-
";
$tableparts = array();
foreach( $overall as $n => $o ) {
	if( $o == 0 ) {
		$stats['zero']++;
	} elseif ( $o >= 1 && $o <= 10 ) {
		$stats['1to10']++;
	} elseif ( $o >= 11 && $o <= 50 ) {
		$stats['11to50']++;
	} elseif ( $o >= 51 && $o <= 100 ) {
		$stats['51to100']++;
	} elseif ( $o >= 101 && $o <= 250 ) {
		$stats['101to250']++;
	} elseif ( $o >= 251 && $o <= 1000 ) {
		$stats['251to1000']++;
	} elseif ( $o >= 1001 && $o <= 2500 ) {
		$stats['1001to2500']++;
	} elseif ( $o >= 2501 ) {
		$stats['2501plus']++;
	}
	$tablepart = "| $n
| " . $overall[$n] . "
| " . $mwonly[$n] . "
| " . $outtauserspace[$n] . "
";
	array_push( $tableparts, $tablepart );
}
$table .= implode( "|-\n", $tableparts );
$table .= "|}
";
echo "{| class='wikitable'
|-
! 0
! >= 1 <= 10
! >= 11 <= 50
! >= 51 <= 100
! >= 101 <= 250
! >= 251 <= 1000
! >= 1000 <= 2500
! >= 2501
|-
| " . $stats['zero'] ."
| " . $stats['1to10'] ."
| " . $stats['11to50'] ."
| " . $stats['51to100'] ."
| " . $stats['101to250'] ."
| " . $stats['251to1000'] ."
| " . $stats['1001to2500'] ."
| " . $stats['2501plus'] ."
|}
";

echo "\n\n$table\n\n";
?>

These queries are variations the often cited "On the top five wikis, 75% of admins have never edited CSS/JS; 92% of admins have almost never done so." query. The thing is - we need to look in the context of editing other users css/js as well. This presents far different numbers:

Query results pending

So, whom are the actual active admins here?

Query results pending