r85411 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r85410‎ | r85411 | r85412 >
Date:01:25, 5 April 2011
Author:diederik
Status:deferred
Tags:
Comment:
A bit of streamlining and storing the average edit count instead of storing '1'.
Modified paths:
  • /trunk/tools/editor_trends/analyses/plugins/taxonomy_burnout.py (modified) (history)

Diff [purge]

Index: trunk/tools/editor_trends/analyses/plugins/taxonomy_burnout.py
@@ -12,8 +12,8 @@
1313 http://www.fsf.org/licenses/gpl.html
1414 '''
1515
16 -__author__ = '''\n'''.join(['Ryan Faulkner (rfaulkner@wikimedia.org)', ])
17 -__email__ = 'dvanliere at gmail dot com'
 16+__author__ = '''\n'''.join(['Diederik van Liere (dvanliere@wikimedia.org', 'Ryan Faulkner (rfaulkner@wikimedia.org)'])
 17+__email__ = 'dvanliere at wikimedia dot org'
1818 __date__ = '2011-01-25'
1919 __version__ = '0.1'
2020
@@ -22,32 +22,31 @@
2323 def taxonomy_burnout(var, editor, **kwargs):
2424 new_wikipedian = editor['new_wikipedian']
2525 edits = editor['monthly_edits']
 26+ cutoff = kwargs.pop('cutoff')
2627
2728 burnout = False
2829 sum = 0.0
2930 count = 0.0
3031
3132 for year in xrange(2001, var.max_year):
 33+ year = str(year)
3234 for month in xrange(1, 13):
33 - str_year = str(year)
34 - str_month = str(month)
35 -
 35+ month = str(month)
3636 try:
37 - if edits[str_year][str_month] > 149:
 37+ if edits[year][month] > 149:
3838 burnout = True
3939 if burnout == True:
40 - sum += edits[str_year][str_month]
41 - count += 1.0
 40+ sum += edits[year][month]
 41+ count += 1.0
4242 except (AttributeError, KeyError):
43 - # print 'Editor ' + editor['username'] + ' does not have data for year ' + str_year + ' and month ' + str_month
44 - pass
 43+ print 'Editor %s does not have data for year: %s and month %s' % (editor['username'], year, month)
4544
46 - if count > 0.0 and sum / count < 10 and burnout == True:
 45+ if burnout and sum / count > 10:
 46+ avg_edit = sum / count
4747
4848 try:
49 - var.add(editor['new_wikipedian'], 1, {'username' : editor['username']})
50 - except:
51 - print 'error: ' + editor['username']
52 - pass
 49+ var.add(new_wikipedian, avg_edit, {'username' : editor['username']})
 50+ except Exception, error:
 51+ print 'user: %s error: %s' %(editor['username'], error)
5352
5453 return var