Index: trunk/tools/editor_trends/analyses/plugins/taxonomy_burnout.py |
— | — | @@ -12,8 +12,8 @@ |
13 | 13 | http://www.fsf.org/licenses/gpl.html |
14 | 14 | ''' |
15 | 15 | |
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' |
18 | 18 | __date__ = '2011-01-25' |
19 | 19 | __version__ = '0.1' |
20 | 20 | |
— | — | @@ -22,32 +22,31 @@ |
23 | 23 | def taxonomy_burnout(var, editor, **kwargs): |
24 | 24 | new_wikipedian = editor['new_wikipedian'] |
25 | 25 | edits = editor['monthly_edits'] |
| 26 | + cutoff = kwargs.pop('cutoff') |
26 | 27 | |
27 | 28 | burnout = False |
28 | 29 | sum = 0.0 |
29 | 30 | count = 0.0 |
30 | 31 | |
31 | 32 | for year in xrange(2001, var.max_year): |
| 33 | + year = str(year) |
32 | 34 | for month in xrange(1, 13): |
33 | | - str_year = str(year) |
34 | | - str_month = str(month) |
35 | | - |
| 35 | + month = str(month) |
36 | 36 | try: |
37 | | - if edits[str_year][str_month] > 149: |
| 37 | + if edits[year][month] > 149: |
38 | 38 | burnout = True |
39 | 39 | if burnout == True: |
40 | | - sum += edits[str_year][str_month] |
41 | | - count += 1.0 |
| 40 | + sum += edits[year][month] |
| 41 | + count += 1.0 |
42 | 42 | 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) |
45 | 44 | |
46 | | - if count > 0.0 and sum / count < 10 and burnout == True: |
| 45 | + if burnout and sum / count > 10: |
| 46 | + avg_edit = sum / count |
47 | 47 | |
48 | 48 | 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) |
53 | 52 | |
54 | 53 | return var |