summaryrefslogtreecommitdiff
path: root/show-edit-counts.rb
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2014-01-23 11:48:35 -0500
committerLuke Shumaker <LukeShu@sbcglobal.net>2014-01-23 11:48:35 -0500
commit4d9129e7436d87ca0228d7e8e02c527873b660f1 (patch)
tree91ae271f67519acf0f38ee0f4d00638bcb570fed /show-edit-counts.rb
initial commit
Diffstat (limited to 'show-edit-counts.rb')
-rwxr-xr-xshow-edit-counts.rb44
1 files changed, 44 insertions, 0 deletions
diff --git a/show-edit-counts.rb b/show-edit-counts.rb
new file mode 100755
index 0000000..d20a812
--- /dev/null
+++ b/show-edit-counts.rb
@@ -0,0 +1,44 @@
+#!/usr/bin/env ruby
+# -*- coding: utf-8 -*-
+
+load 'mwapi.rb'
+require 'yaml'
+
+mw = MWApi.new('https://wiki.parabolagnulinux.org/api.php')
+credentials = YAML.load_file('credentials.yml')
+mw.login(credentials['username'], credentials['password'])
+
+aufrom = ''
+while not aufrom.nil? do
+ audata = mw.query(:list => :allusers, :aulimit => 200, :aufrom => aufrom, :auprop => 'blockinfo')
+ for user in audata['query']['allusers']
+ if user['blockid'].nil?
+ deleted_edits = 0 # XXX actually is the number of deleted pages edited, not number of edits
+ existing_edits = 0
+ drcontinue = ''
+ while not drcontinue.nil?
+ drdata = mw.query(:list => :deletedrevs, :druser => user['name'], :drlimit => 200)
+ deleted_edits += drdata['query']['deletedrevs'].length
+ drcontinue = nil
+ end
+ uccontinue = ''
+ while not uccontinue.nil?
+ ucdata = mw.query(:list => :usercontribs, :ucuser => user['name'], :uclimit => 200, :uccontinue => uccontinue)
+ existing_edits += ucdata['query']['usercontribs'].length
+ if ucdata['query-continue'].nil?
+ uccontinue = nil
+ else
+ uccontinue = ucdata['query-continue']['usercontribs']['uccontinue']
+ end
+ end
+ print "Username: #{user['name']}\tdeleted: #{deleted_edits}\texisting: #{existing_edits}\n"
+ else
+ print "Username: #{user['name']}\tblockreason: #{user['blockreason']}\n"
+ end
+ end
+ if audata['query-continue'].nil?
+ aufrom = nil
+ else
+ aufrom = audata['query-continue']['allusers']['aufrom']
+ end
+end