r84965 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r84964‎ | r84965 | r84966 >
Date:15:53, 29 March 2011
Author:diederik
Status:deferred
Tags:
Comment:
Updated plugins to reflect changes in datamodel.
Modified paths:
  • /trunk/tools/editor_trends/analyses/plugins/cohort_dataset_backward_bar.py (modified) (history)
  • /trunk/tools/editor_trends/analyses/plugins/cohort_dataset_forward_bar.py (modified) (history)
  • /trunk/tools/editor_trends/analyses/plugins/cohort_dataset_forward_histogram.py (modified) (history)
  • /trunk/tools/editor_trends/analyses/plugins/edit_patterns.py (modified) (history)
  • /trunk/tools/editor_trends/analyses/plugins/histogram_by_backward_cohort.py (modified) (history)
  • /trunk/tools/editor_trends/analyses/plugins/histogram_edits.py (modified) (history)
  • /trunk/tools/editor_trends/analyses/plugins/time_to_new_wikipedian.py (modified) (history)
  • /trunk/tools/editor_trends/analyses/plugins/total_number_of_new_wikipedians.py (modified) (history)

Diff [purge]

Index: trunk/tools/editor_trends/analyses/plugins/cohort_dataset_forward_bar.py
@@ -31,7 +31,7 @@
3232 yearly_edits = editor['edits_by_year']
3333 n = editor['edit_count']
3434
35 - if n >= var.cum_cutoff:
 35+ if n >= var.cum_cutoff and new_wikipedian != False:
3636 for year in xrange(new_wikipedian.year, var.max_year):
3737 max_edits = max(monthly_edits.get(str(year), {0:0}).values())
3838 if yearly_edits.get(str(year), 0) == 0 or max_edits < var.cutoff:
Index: trunk/tools/editor_trends/analyses/plugins/time_to_new_wikipedian.py
@@ -18,9 +18,14 @@
1919 __version__ = '0.1'
2020
2121 def time_to_new_wikipedian(var, editor, **kwargs):
22 -# headers = ['year', 'time_to_new_wikipedian']
 22+ '''
 23+ This plugin calculates how long it takes for an editor to become a
 24+ new wikipedian. A new wikipedian is defined as someone who has made 10
 25+ edits
 26+ '''
2327 new_wikipedian = editor['new_wikipedian']
24 - first_edit = editor['first_edit']
25 - dt = new_wikipedian - first_edit
26 - var.add(new_wikipedian, dt.days)
 28+ if new_wikipedian != False:
 29+ first_edit = editor['first_edit']
 30+ dt = new_wikipedian - first_edit
 31+ var.add(new_wikipedian, dt.days)
2732 return var
Index: trunk/tools/editor_trends/analyses/plugins/total_number_of_new_wikipedians.py
@@ -20,6 +20,8 @@
2121
2222
2323 def total_number_of_new_wikipedians(var, editor, **kwargs):
 24+
2425 new_wikipedian = editor['new_wikipedian']
25 - var.add(new_wikipedian, 1, {'year':new_wikipedian.year})
 26+ if new_wikipedian != False:
 27+ var.add(new_wikipedian, 1, {'year':new_wikipedian.year})
2628 return var
Index: trunk/tools/editor_trends/analyses/plugins/histogram_by_backward_cohort.py
@@ -26,7 +26,7 @@
2727 new_wikipedian = editor['new_wikipedian']
2828 n = editor['edit_count']
2929
30 - if n >= var.cum_cutoff:
 30+ if n >= var.cum_cutoff and new_wikipedian != False:
3131 windows = data_converter.create_windows(var, break_down_first_year=break_down)
3232 for year in xrange(new_wikipedian.year, var.max_year):
3333 year = str(year)
Index: trunk/tools/editor_trends/analyses/plugins/cohort_dataset_forward_histogram.py
@@ -22,7 +22,6 @@
2323 import calendar
2424
2525 def cohort_dataset_forward_histogram(var, editor, **kwargs):
26 -# headers = ['year', 'month', 'edits']
2726 '''
2827 The forward looking histogram looks for every month that an editor
2928 was part of the Wikimedia community whether this person made at least cutoff
@@ -35,7 +34,7 @@
3635 yearly_edits = editor['edits_by_year']
3736 n = editor['edit_count']
3837
39 - if n >= var.cum_cutoff:
 38+ if n >= var.cum_cutoff and new_wikipedian != False:
4039 for year in xrange(new_wikipedian.year, final_edit):
4140 edits = editor['monthly_edits'].get(str(year), {0:0})
4241 if year == new_wikipedian.year:
Index: trunk/tools/editor_trends/analyses/plugins/cohort_dataset_backward_bar.py
@@ -33,7 +33,7 @@
3434 new_wikipedian = editor['new_wikipedian']
3535 n = editor['edit_count']
3636
37 - if n >= var.cum_cutoff:
 37+ if n >= var.cum_cutoff and new_wikipedian != False:
3838 windows = data_converter.create_windows(var, break_down_first_year=break_down)
3939 for year in xrange(new_wikipedian.year, var.max_year):
4040 year = str(year)
Index: trunk/tools/editor_trends/analyses/plugins/edit_patterns.py
@@ -27,12 +27,13 @@
2828 if dt.days < 366:
2929 return var
3030
31 - for year in xrange(new_wikipedian.year, new_wikipedian.year + 2):
32 - obs = [False for x in xrange(13)]
33 - for month in xrange(new_wikipedian.month, 13):
34 - n = monthly[str(year)][str(month)]
35 - date = datetime.datetime(year, month, 1)
36 - if n >= var.cutoff:
37 - obs[month] = True
38 - var.add(date, obs)
 31+ if new_wikipedian != False:
 32+ for year in xrange(new_wikipedian.year, new_wikipedian.year + 2):
 33+ 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:
 38+ obs[month] = True
 39+ var.add(date, obs)
3940 return var
Index: trunk/tools/editor_trends/analyses/plugins/histogram_edits.py
@@ -22,5 +22,6 @@
2323 # headers = ['year', 'num_edits', 'frequency']
2424 cnt = editor['edit_count']
2525 new_wikipedian = editor['new_wikipedian']
26 - var.add(new_wikipedian, cnt)
 26+ if new_wikipedian != False:
 27+ var.add(new_wikipedian, cnt)
2728 return var