r85408 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r85407‎ | r85408 | r85409 >
Date:00:45, 5 April 2011
Author:rfaulk
Status:deferred
Tags:
Comment:
fixed issues with adding records to Variable (dataset.py) objects. Handled exceptions where 'month' and 'year' elements of 'edits' collection do not exist.
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
@@ -24,18 +24,30 @@
2525 edits = editor['monthly_edits']
2626
2727 burnout = False
28 - sum =0.0
 28+ sum = 0.0
2929 count = 0.0
3030
31 - for year in xrange(new_wikipedian.year, var.max_year):
 31+ for year in xrange(2001, var.max_year):
3232 for month in xrange(1, 13):
33 - if edits[str(year)][str(month)] > 249:
34 - burnout = True
35 - if burnout == True:
36 - sum += edits[str(year)][str(month)]
37 - count +=1.0
 33+ str_year = str(year)
 34+ str_month = str(month)
3835
39 - if sum / count < 10 and burnout == True:
40 - var.add(editor['username'], 1)
41 -
 36+ try:
 37+ if edits[str_year][str_month] > 149:
 38+ burnout = True
 39+ if burnout == True:
 40+ sum += edits[str_year][str_month]
 41+ count += 1.0
 42+ except (AttributeError, KeyError):
 43+ # print 'Editor ' + editor['username'] + ' does not have data for year ' + str_year + ' and month ' + str_month
 44+ pass
 45+
 46+ if count > 0.0 and sum / count < 10 and burnout == True:
 47+
 48+ try:
 49+ var.add(editor['new_wikipedian'], 1, {'username' : editor['username']})
 50+ except:
 51+ print 'error: ' + editor['username']
 52+ pass
 53+
4254 return var