User:Rick Block/adminactivity
From Wikipedia, the free encyclopedia
[edit] Script
This is a script that will create files containing active, semiactive, and inactive administrators. The criteria is:
- Active - at least 30 edits in the last 2 months
- Semiactive - not active, and at least one edit in last 3 months
- Inactive - no edits in last 3 months
NOTE: do not yank and put the output directly into WP:LA since it does not include contact information and various other notes added to entries on this page.
NOTE: the list of inactives from this script is not sorted by length of inactivity
Rick Block (talk) 17:51, July 23, 2005 (UTC)
#!/bin/bash WGET="/usr/bin/curl" # on a mac OS X # WGET="wget -q -O -" # on a linux box with wget # files ACTIVE="admins.active" SEMIACTIVE="admins.semiactive" INACTIVE="admins.inactive" CONTRIBS="contrib.times" function prevmonth () { case $1 in January) echo "December";; February) echo "January";; March) echo "February";; April) echo "March";; May) echo "April";; June) echo "May";; July) echo "June";; August) echo "July";; September) echo "August";; October) echo "September";; November) echo "October";; December) echo "November";; esac } function inactive () { # $1 is day number of latest contrib # $2 is month of latest contrib # $3 is year of latest contrib # $4 - $6 are day, month, year for today # if latest contrib is this month, not inactive [ $2 = $5 -a $3 = $6 ] && return 1 # if latest contrib is last month, not inactive MONTH=`prevmonth $5` YEAR=$6 [ $MONTH = "December" ] && let YEAR=$YEAR-1 [ $2 = $MONTH -a $3 = $YEAR ] && return 1 # if latest contrib is two months ago, not inactive MONTH=`prevmonth $MONTH` [ $MONTH = "December" ] && let YEAR=$YEAR-1 [ $2 = $MONTH -a $3 = $YEAR ] && return 1 # if latest contrib is less than three months ago, not inactive MONTH=`prevmonth $MONTH` [ $MONTH = "December" ] && let YEAR=$YEAR-1 [ $2 = $MONTH -a $3 = $YEAR -a $1 -gt $4 ] && return 1 return 0 } function semiactive () { # $1 is day number of 30th most recent contrib # $2 is month of 30th most recent contrib # $3 is year of 30th most recent contrib # $4 - $6 are day, month, year for today # if 30th most recent contrib is this month, not semi-active if [ $2 = $5 -a $3 = $6 ]; then return 1 fi # if 30th most recent contrib is last month, not semi-active MONTH=`prevmonth $5` YEAR=$6 [ $MONTH = "December" ] && let YEAR=$YEAR-1 [ $2 = $MONTH -a $3 = $YEAR ] && return 1 # if 30th most recent contrib is less than two months ago, not semi-active MONTH=`prevmonth $MONTH` [ $MONTH = "December" ] && let YEAR=$YEAR-1 [ $2 = $MONTH -a $3 = $YEAR -a $1 -gt $4 ] && return 1 return 0 } TODAY=`date +"%e %B %Y"` rm -f $ACTIVE rm -f $INACTIVE rm -f $SEMIACTIVE let n=1 $WGET 'http://en.wikipedia.org/w/index.php?title=Special%3aListusers&group=sysop&limit=1000' | grep -F "<li>" | sed 's/^.*<li><a href="\/wiki\/User://' | sed 's/">.*//' | while read line; do let n=n+1 if [ $n -ge 10 ]; then sleep 10 let n=1 fi urlname=${line%%\" title=\"User:*} realname=${line##*\" title=\"User:} $WGET "http://en.wikipedia.org/w/index.php?title=Special:Contributions&target=$urlname&limit=30" | grep -F "<li>" | sed -e 's/^.*<li>//' -e 's/ (.*//' >$CONTRIBS.$urlname LATEST=`head -1 $CONTRIBS.$urlname | cut -c8-` THIRTIETH=`tail -1 $CONTRIBS.$urlname | cut -c8-` # inactive if LATEST contrib not within last three months # semi-active if 30th most recent contrib is more than two months ago inactive $LATEST $TODAY if [ $? -eq 0 ]; then case "$urlname" in Jasonr) echo "# {{subst:User|$realname}} - has administrator access for technical rather than administrative reasons. Works on hardware upgrades." >> $INACTIVE;; *) echo "# {{subst:User|$realname}} - inactive since $LATEST" >>$INACTIVE;; esac continue fi semiactive $THIRTIETH $TODAY if [ $? -eq 0 ]; then echo "# {{admin|$realname|$realname}}" >>$SEMIACTIVE else echo "# {{admin|$realname|$realname}}" >>$ACTIVE fi done # fix the sort order sort -fd $SEMIACTIVE >tmp.$SEMIACTIVE mv tmp.$SEMIACTIVE $SEMIACTIVE sort -fd $ACTIVE >tmp.$ACTIVE mv tmp.$ACTIVE $ACTIVE