blob: 4abd3101e343a589ac63905b64e4a8bd67fdd7dd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
load 'mwapi.rb'
require 'yaml'
require 'pp'
mw = MWApi.new('https://wiki.parabolagnulinux.org/api.php')
credentials = YAML.load_file('credentials.yml')
mw.login(credentials['username'], credentials['password'])
userqueue = []
aufrom = ''
while not aufrom.nil? do
audata = mw.query(
:list => :allusers,
:auprop => 'blockinfo|editcount|registration',
:aulimit => 5000,
:aufrom => aufrom)
for user in audata['query']['allusers']
if user['blockid'].nil?
if user['editcount'] == 0
# optimize 0 edits means we don't need to count how many aren't deleted
print "name: #{user['name']}\tregistration: #{user['registration']}\ttotal_editcount: 0\texisting_editcount: 0\n"
else
# queue this user for counting how many live edits they have
userqueue.push(user)
end
else
print "name: #{user['name']}\tregistration: #{user['registration']}\tblockreason: #{user['blockreason']}\n"
end
end
aufrom = (audata['query-continue'].nil?) ? nil : audata['query-continue']['allusers']['aufrom']
end
userqueue.each_slice(5000) do |userlist|
contribcount = {}
uccontinue = ''
while not uccontinue.nil?
query = {
:list => :usercontribs,
:ucuser => (userlist.map{|u| u['name']}).join('|'),
:uclimit => 5000,
}
if uccontinue.length > 0
query.merge!({:uccontinue => uccontinue})
end
ucdata = mw.query(query)
ucdata['query']['usercontribs'].each do |contrib|
contribcount[contrib['user']] ||= 0
contribcount[contrib['user']] += 1
end
uccontinue = (ucdata['query-continue'].nil?) ? nil : ucdata['query-continue']['usercontribs']['uccontinue']
end
userlist.each do |user|
print "name: #{user['name']}\tregistration: #{user['registration']}\ttotal_editcount: #{user['editcount']}\texisting_editcount: #{contribcount[user['name']]}\n"
end
end
|