User:SQL/Admin CSS-JS Editing
{{collapse top|title=Source code}}
$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 page_title, page_namespace, rev_comment from page join revision_userindex on rev_page = page_id where (page_namespace = 2 OR page_namespace = 8) and rev_user = '$uid' and page_title rlike '^.*\.(css|js)$';";
$newR = mysqli_query( $mysqli, $newQ );
while( $uRow = mysqli_fetch_assoc( $newR ) ) {
$comment = $uRow['rev_comment'];
$title = $uRow['page_title'];
$namespace = $uRow['page_namespace'];
$moves = '/moved page \[\[(?!.*?WP:AFCH)|moved \[\[.*?\]\] to \[\[/i';
$protects = '/^(Protected|Changed protection).*?\[[Ee]dit=|^Removed protection from|^Configured pending changes.*?\[[Aa]uto-accept|^Reset pending changes settings/i';
if( preg_match( "/^.*\.(css|js)$/i", $title ) == 1 && preg_match( $moves, $comment ) == 0 && preg_match( $protects, $comment ) ) {
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";
?>
{{collapse bottom}}
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." [https://phabricator.wikimedia.org/T190015#4203100 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: (Script is currently running to calculate edits, and not just pages edited, as well as to filter out protections and moves)
class='wikitable' |
0
! >= 1 <= 10 ! >= 11 <= 50 ! >= 51 <= 100 ! >= 101 <= 250 ! >= 251 <= 1000 ! >= 1000 <= 2500 ! >= 2501 |
---|
722
| 389 | 62 | 12 | 17 | 7 | 2 | 0 |
So, whom are the actual active admins here?
1 Year
Edits 1 year and newer
class='wikitable' |
0
! >= 1 <= 10 ! >= 11 <= 50 ! >= 51 <= 100 ! >= 101 <= 250 ! >= 251 <= 1000 ! >= 1000 <= 2500 ! >= 2501 |
---|
1152
| 47 | 10 | 1 | 0 | 1 | 0 | 0 |
class='wikitable sortable' |
Name
! Overall JS/CSS Edits ! MW JS/CSS Edits ! Userspace JS/CSS Edits |
---|
User:TheDJ
| 313 | 220 | 93 |
User:MusikAnimal
| 61 | 50 | 11 |
User:Redrose64
| 49 | 42 | 7 |
User:Ragesoss
| 40 | 40 | 0 |
User:Pharos
| 39 | 39 | 0 |
User:Amorymeltzer
| 29 | 5 | 24 |
User:Xaosflux
| 29 | 12 | 17 |
User:There'sNoTime
| 24 | 22 | 2 |
User:Meno25
| 23 | 0 | 23 |
User:MSGJ
| 20 | 15 | 5 |
User:Dinoguy1000
| 14 | 14 | 0 |
User:Mr._Stradivarius
| 12 | 10 | 2 |
User:Primefac
| 9 | 0 | 9 |
User:Ocaasi
| 7 | 7 | 0 |
User:Andrew_Gray
| 6 | 6 | 0 |
User:Plastikspork
| 6 | 0 | 6 |
User:Deryck_Chan
| 5 | 5 | 0 |
User:Timotheus_Canens
| 4 | 0 | 4 |
User:GoldenRing
| 4 | 4 | 0 |
User:Ruslik0
| 4 | 0 | 4 |
User:Wbm1058
| 4 | 0 | 4 |
User:Cyberpower678
| 3 | 1 | 2 |
User:Legoktm
| 3 | 1 | 2 |
User:Doc_James
| 3 | 0 | 3 |
User:TonyBallioni
| 3 | 0 | 3 |
User:OhanaUnited
| 2 | 2 | 0 |
User:Hut_8.5
| 2 | 0 | 2 |
User:BD2412
| 2 | 0 | 2 |
User:Oshwah
| 2 | 0 | 2 |
User:Smith609
| 2 | 2 | 0 |
User:DrKay
| 1 | 0 | 1 |
User:Anachronist
| 1 | 0 | 1 |
User:Trappist_the_monk
| 1 | 1 | 0 |
User:Bearcat
| 1 | 0 | 1 |
User:Rosiestep
| 1 | 0 | 1 |
User:RHaworth
| 1 | 0 | 1 |
User:Calliopejen1
| 1 | 1 | 0 |
User:HJ_Mitchell
| 1 | 1 | 0 |
User:R'n'B
| 1 | 0 | 1 |
User:Killiondude
| 1 | 1 | 0 |
User:DMacks
| 1 | 1 | 0 |
User:PrimeHunter
| 1 | 0 | 1 |
User:Nihiltres
| 1 | 1 | 0 |
User:Kusma
| 1 | 0 | 1 |
User:Jason_Quinn
| 1 | 1 | 0 |
User:Czar
| 1 | 0 | 1 |
User:SQL
| 1 | 0 | 1 |
User:Alex_Shih
| 1 | 1 | 0 |
User:Floquenbeam
| 1 | 0 | 1 |
User:Kudpung
| 1 | 0 | 1 |
User:Premeditated_Chaos
| 1 | 0 | 1 |
User:BrownHairedGirl
| 1 | 0 | 1 |
User:SoWhy
| 1 | 0 | 1 |
User:Writ_Keeper
| 1 | 1 | 0 |
User:MER-C
| 1 | 0 | 1 |
User:Jo-Jo_Eumerus
| 1 | 0 | 1 |
User:TheSandDoctor
| 1 | 0 | 1 |
User:Mz7
| 1 | 0 | 1 |
User:Nick
| 1 | 0 | 1 |
3 Years
Edits 3 years and newer
Script running