Index: trunk/tools/editor_trends/analyses/plugins/total_cumulative_edits.py |
— | — | @@ -17,9 +17,22 @@ |
18 | 18 | __date__ = '2011-01-25' |
19 | 19 | __version__ = '0.1' |
20 | 20 | |
| 21 | +from datetime import datetime |
21 | 22 | |
22 | 23 | def total_cumulative_edits(var, editor, **kwargs): |
23 | | - cnt = editor['edit_count'] |
24 | | - last = editor['final_edit'] |
25 | | - var.add(last, cnt, {'year': last.year}) |
| 24 | + ''' |
| 25 | + If you have questions about how to use this plugin, please visit: |
| 26 | + http://meta.wikimedia.org/wiki/Wikilytics_Plugins |
| 27 | + ''' |
| 28 | + namespace = kwargs.get('namespace', ['0']) |
| 29 | + edits = editor['edit_count'] |
| 30 | + years = edits.keys() |
| 31 | + for year in years: |
| 32 | + months = edits[year].keys() |
| 33 | + for month in months: |
| 34 | + date = datetime(int(year), int(month), 1) |
| 35 | + for ns in namespace: |
| 36 | + count = edits[year][month].get(ns, 0) |
| 37 | + if count > 0: |
| 38 | + var.add(date, count, {'namespace': ns}) |
26 | 39 | return var |
Index: trunk/tools/editor_trends/analyses/plugins/taxonomy_list_makers.py |
— | — | @@ -20,23 +20,24 @@ |
21 | 21 | def taxonomy_list_makers(var, editor, **kwargs): |
22 | 22 | """ |
23 | 23 | == List makers == |
24 | | - Any editor who makes more than 10 mainspace edits a month to articles with titles that begin with "List of..." |
25 | | - """ |
| 24 | + Any editor who makes more than 10 mainspace edits a month to articles with |
| 25 | + titles that begin with "List of..." |
| 26 | + """ |
26 | 27 | articles_by_year = editor['articles_by_year'] |
27 | 28 | count = 0 |
28 | | - |
| 29 | + |
29 | 30 | for year in xrange(new_wikipedian.year, var.max_year): |
30 | 31 | for month in xrange(1, 13): |
31 | 32 | for article in articles_by_year[year][month]: |
32 | 33 | """ locate article titles containing "List of" """ |
33 | 34 | if article.find('List of') > -1: |
34 | 35 | count = count + 1 |
35 | | - |
36 | | - |
| 36 | + |
| 37 | + |
37 | 38 | """ Add all editors with an edit count of more than 10 """ |
38 | 39 | |
39 | 40 | if count > 10: |
40 | 41 | var.add(editor['username'], 1) |
41 | | - |
42 | | - |
| 42 | + |
| 43 | + |
43 | 44 | return var |
Index: trunk/tools/editor_trends/analyses/plugins/taxonomy_burnout.py |
— | — | @@ -12,17 +12,20 @@ |
13 | 13 | http://www.fsf.org/licenses/gpl.html |
14 | 14 | ''' |
15 | 15 | |
16 | | -__author__ = '''\n'''.join(['Diederik van Liere (dvanliere@wikimedia.org', 'Ryan Faulkner (rfaulkner@wikimedia.org)']) |
| 16 | +__author__ = '''\n'''.join(['Diederik van Liere (dvanliere@wikimedia.org', |
| 17 | + 'Ryan Faulkner (rfaulkner@wikimedia.org)']) |
17 | 18 | __email__ = 'dvanliere at wikimedia dot org' |
18 | 19 | __date__ = '2011-01-25' |
19 | 20 | __version__ = '0.1' |
20 | 21 | |
21 | 22 | |
22 | | - |
23 | 23 | def taxonomy_burnout(var, editor, **kwargs): |
| 24 | + ''' |
| 25 | + If you have questions about how to use this plugin, please visit: |
| 26 | + http://meta.wikimedia.org/wiki/Wikilytics_Plugins |
| 27 | + ''' |
24 | 28 | new_wikipedian = editor['new_wikipedian'] |
25 | 29 | edits = editor['edit_count'] |
26 | | - final_edit = editor['final_edit'] |
27 | 30 | cutoff = kwargs.get('cutoff', 149) |
28 | 31 | username = editor['username'] |
29 | 32 | |
Index: trunk/tools/editor_trends/analyses/plugins/total_number_of_new_wikipedians.py |
— | — | @@ -20,8 +20,11 @@ |
21 | 21 | |
22 | 22 | |
23 | 23 | def total_number_of_new_wikipedians(var, editor, **kwargs): |
24 | | - |
| 24 | + ''' |
| 25 | + If you have questions about how to use this plugin, please visit: |
| 26 | + http://meta.wikimedia.org/wiki/Wikilytics_Plugins |
| 27 | + ''' |
25 | 28 | new_wikipedian = editor['new_wikipedian'] |
26 | 29 | if new_wikipedian != False: |
27 | | - var.add(new_wikipedian, 1, {'year':new_wikipedian.year}) |
| 30 | + var.add(new_wikipedian, 1) |
28 | 31 | return var |
Index: trunk/tools/editor_trends/analyses/plugins/edit_patterns.py |
— | — | @@ -17,23 +17,31 @@ |
18 | 18 | __date__ = '2011-01-28' |
19 | 19 | __version__ = '0.1' |
20 | 20 | |
21 | | -import datetime |
| 21 | +from datetime import datetime |
22 | 22 | |
23 | 23 | def edit_patterns(var, editor, **kwargs): |
24 | | - monthly = editor['monthly_edits'] |
| 24 | + ''' |
| 25 | + If you have questions about how to use this plugin, please visit: |
| 26 | + http://meta.wikimedia.org/wiki/Wikilytics_Plugins |
| 27 | + ''' |
| 28 | + edits = editor['edit_count'] |
25 | 29 | new_wikipedian = editor['new_wikipedian'] |
26 | 30 | final_edit = editor['final_edit'] |
27 | | - dt = final_edit - new_wikipedian |
28 | | - if dt.days < 366: |
29 | | - return var |
30 | 31 | |
31 | 32 | if new_wikipedian != False: |
32 | | - for year in xrange(new_wikipedian.year, new_wikipedian.year + 2): |
| 33 | + dt = final_edit - new_wikipedian |
| 34 | + if dt.days < 366: |
| 35 | + return var |
| 36 | + |
| 37 | + years = edits.keys() |
| 38 | + for year in years: |
| 39 | + #for year in xrange(new_wikipedian.year, new_wikipedian.year + 2): |
33 | 40 | obs = [False for x in xrange(13)] |
34 | | - for month in xrange(new_wikipedian.month, 13): |
35 | | - n = monthly[str(year)][str(month)] |
36 | | - date = datetime.datetime(year, month, 1) |
37 | | - if n >= var.cutoff: |
| 41 | + months = edit[year].keys() |
| 42 | + for month in xrange(13): |
| 43 | + count = edits[year].get(month, {}).get('0', 0) |
| 44 | + date = datetime(int(year), int(month), 1) |
| 45 | + if count >= var.cutoff: |
38 | 46 | obs[month] = True |
39 | 47 | var.add(date, obs) |
40 | 48 | return var |
Index: trunk/tools/editor_trends/analyses/plugins/histogram_edits.py |
— | — | @@ -17,11 +17,22 @@ |
18 | 18 | __date__ = '2011-01-25' |
19 | 19 | __version__ = '0.1' |
20 | 20 | |
| 21 | +from datetime import datetime |
21 | 22 | |
22 | 23 | def histogram_edits(var, editor, **kwargs): |
23 | | -# headers = ['year', 'num_edits', 'frequency'] |
24 | | - cnt = editor['edit_count'] |
25 | | - new_wikipedian = editor['new_wikipedian'] |
26 | | - if new_wikipedian != False: |
27 | | - var.add(new_wikipedian, cnt) |
| 24 | + ''' |
| 25 | + If you have questions about how to use this plugin, please visit: |
| 26 | + http://meta.wikimedia.org/wiki/Wikilytics_Plugins |
| 27 | + ''' |
| 28 | + namespace = kwargs.get('namespace', ['0']) |
| 29 | + edits = editor['edit_count'] |
| 30 | + years = edits.keys() |
| 31 | + for year in years: |
| 32 | + months = edits[year].keys() |
| 33 | + for month in months: |
| 34 | + date = datetime(int(year), int(month), 1) |
| 35 | + for ns in namespace: |
| 36 | + count = edits[year][month].get(ns, 0) |
| 37 | + if count > 0: |
| 38 | + var.add(date, 1, {'namespace': ns, 'number_of_edits': count}) |
28 | 39 | return var |
Index: trunk/tools/editor_trends/analyses/plugins/total_number_of_articles.py |
— | — | @@ -17,8 +17,12 @@ |
18 | 18 | __date__ = '2011-01-25' |
19 | 19 | __version__ = '0.1' |
20 | 20 | |
| 21 | +import sys |
21 | 22 | |
22 | 23 | def total_number_of_articles(var, editor, **kwargs): |
| 24 | + print 'This plugin is not yet functional, needs to be rewritten.' |
| 25 | + sys.exit(-1) |
| 26 | + |
23 | 27 | for year in editor['edits']: |
24 | 28 | edits = editor['edits'][year] |
25 | 29 | for edit in edits: |
Index: trunk/tools/editor_trends/analyses/plugins/new_editor_count.py |
— | — | @@ -25,7 +25,6 @@ |
26 | 26 | Purpose: This data can be used to compare with Erik Zachte's |
27 | 27 | stats.download.org to make sure that we are using the same numbers. |
28 | 28 | ''' |
29 | | -# headers = ['year', 'month', 'count'] |
30 | 29 | if editor['new_wikipedian'] != False: |
31 | 30 | new_wikipedian = editor['new_wikipedian'] |
32 | 31 | var.add(new_wikipedian, 1) |