User:SQL/Admin CSS-JS Editing
Appearance
< User:SQL
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 = "| [[User:$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 - as this will be part of the restriction. Admins won't be able to edit or delete other users js/css (won't be able to help with scripts). It's unclear at this point if oversighters will be able to remove revisions from css/js.
My script presents far different (and more complete) numbers:
Query results pending
So, whom are the actual active admins here?
Query results pending