r85457 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r85456‎ | r85457 | r85458 >
Date:19:01, 5 April 2011
Author:diederik
Status:deferred
Tags:
Comment:
Renamed the specific Editor Trends Study plugins and updated the code for Wikilytics 0.2
Modified paths:
  • /trunk/tools/editor_trends/analyses/plugins/cohort_dataset_backward_bar.py (deleted) (history)
  • /trunk/tools/editor_trends/analyses/plugins/cohort_dataset_forward_bar.py (deleted) (history)
  • /trunk/tools/editor_trends/analyses/plugins/cohort_dataset_forward_histogram.py (deleted) (history)
  • /trunk/tools/editor_trends/analyses/plugins/ets_cohort_backward_bar.py (added) (history)
  • /trunk/tools/editor_trends/analyses/plugins/ets_cohort_backward_histogram.py (added) (history)
  • /trunk/tools/editor_trends/analyses/plugins/ets_cohort_forward_bar.py (added) (history)
  • /trunk/tools/editor_trends/analyses/plugins/ets_cohort_forward_histogram.py (added) (history)
  • /trunk/tools/editor_trends/analyses/plugins/histogram_by_backward_cohort.py (deleted) (history)

Diff [purge]

Index: trunk/tools/editor_trends/analyses/plugins/cohort_dataset_forward_bar.py
@@ -1,42 +0,0 @@
2 -#!/usr/bin/python
3 -# -*- coding: utf-8 -*-
4 -'''
5 -Copyright (C) 2010 by Diederik van Liere (dvanliere@gmail.com)
6 -This program is free software; you can redistribute it and/or
7 -modify it under the terms of the GNU General Public License version 2
8 -as published by the Free Software Foundation.
9 -This program is distributed in the hope that it will be useful,
10 -but WITHOUT ANY WARRANTY; without even the implied warranty of
11 -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 -See the GNU General Public License for more details, at
13 -http://www.fsf.org/licenses/gpl.html
14 -'''
15 -
16 -__author__ = '''\n'''.join(['Diederik van Liere (dvanliere@gmail.com)', ])
17 -__email__ = 'dvanliere at gmail dot com'
18 -__date__ = '2011-01-25'
19 -__version__ = '0.1'
20 -
21 -
22 -def cohort_dataset_forward_bar(var, editor, **kwargs):
23 - '''
24 - The forward looking bar charts looks for every month that an editor
25 - was part of the Wikimedia community whether this person made at least cutoff
26 - value edits. If yes, then include this person in the analysis, else skip the
27 - person.
28 - '''
29 - new_wikipedian = editor['new_wikipedian']
30 - last_edit = editor['final_edit']
31 - monthly_edits = editor['monthly_edits']
32 - yearly_edits = editor['edits_by_year']
33 - n = editor['edit_count']
34 -
35 - if n >= var.cum_cutoff and new_wikipedian != False:
36 - for year in xrange(new_wikipedian.year, var.max_year):
37 - max_edits = max(monthly_edits.get(str(year), {0:0}).values())
38 - if yearly_edits.get(str(year), 0) == 0 or max_edits < var.cutoff:
39 - continue
40 - else:
41 - experience = (year - new_wikipedian.year) + 1
42 - var.add(new_wikipedian, 1, {'experience':experience})
43 - return var
Index: trunk/tools/editor_trends/analyses/plugins/histogram_by_backward_cohort.py
@@ -1,44 +0,0 @@
2 -#!/usr/bin/python
3 -# -*- coding: utf-8 -*-
4 -'''
5 -Copyright (C) 2010 by Diederik van Liere (dvanliere@gmail.com)
6 -This program is free software; you can redistribute it and/or
7 -modify it under the terms of the GNU General Public License version 2
8 -as published by the Free Software Foundation.
9 -This program is distributed in the hope that it will be useful,
10 -but WITHOUT ANY WARRANTY; without even the implied warranty of
11 -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 -See the GNU General Public License for more details, at
13 -http://www.fsf.org/licenses/gpl.html
14 -'''
15 -
16 -__author__ = '''\n'''.join(['Diederik van Liere (dvanliere@gmail.com)', ])
17 -__email__ = 'dvanliere at gmail dot com'
18 -__date__ = '2011-01-31'
19 -__version__ = '0.1'
20 -
21 -import datetime
22 -from dateutil.relativedelta import relativedelta
23 -from utils import data_converter
24 -
25 -def histogram_by_backward_cohort(var, editor, **kwargs):
26 - break_down = kwargs.pop('break_down', False)
27 - new_wikipedian = editor['new_wikipedian']
28 - n = editor['edit_count']
29 -
30 - if n >= var.cum_cutoff and new_wikipedian != False:
31 - windows = data_converter.create_windows(var, break_down_first_year=break_down)
32 - for year in xrange(new_wikipedian.year, var.max_year):
33 - year = str(year)
34 - if editor['edits_by_year'][year] >= var.cutoff:
35 - last_edit = editor['last_edit_by_year'][year]
36 - if last_edit != 0.0:
37 - editor_dt = relativedelta(last_edit, new_wikipedian)
38 - editor_dt = (editor_dt.years * 12) + editor_dt.months
39 - for w in windows:
40 - if w >= editor_dt:
41 - datum = datetime.datetime(int(year), 12, 31)
42 - freq = int(editor['edits_by_year'][year])
43 - var.add(datum, 1, {'window': w, 'frequency': freq})
44 - break
45 - return var
Index: trunk/tools/editor_trends/analyses/plugins/cohort_dataset_forward_histogram.py
@@ -1,52 +0,0 @@
2 -#!/usr/bin/python
3 -# -*- coding: utf-8 -*-
4 -'''
5 -Copyright (C) 2010 by Diederik van Liere (dvanliere@gmail.com)
6 -This program is free software; you can redistribute it and/or
7 -modify it under the terms of the GNU General Public License version 2
8 -as published by the Free Software Foundation.
9 -This program is distributed in the hope that it will be useful,
10 -but WITHOUT ANY WARRANTY; without even the implied warranty of
11 -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 -See the GNU General Public License for more details, at
13 -http://www.fsf.org/licenses/gpl.html
14 -'''
15 -
16 -__author__ = '''\n'''.join(['Diederik van Liere (dvanliere@gmail.com)', ])
17 -__email__ = 'dvanliere at gmail dot com'
18 -__date__ = '2011-01-25'
19 -__version__ = '0.1'
20 -
21 -import datetime
22 -from dateutil.relativedelta import *
23 -import calendar
24 -
25 -def cohort_dataset_forward_histogram(var, editor, **kwargs):
26 - '''
27 - The forward looking histogram looks for every month that an editor
28 - was part of the Wikimedia community whether this person made at least cutoff
29 - value edits. If yes, then include this person in the analysis, else skip the
30 - person.
31 - '''
32 -
33 - new_wikipedian = editor['new_wikipedian']
34 - final_edit = editor['final_edit'].year + 1
35 - yearly_edits = editor['edits_by_year']
36 - n = editor['edit_count']
37 -
38 - if n >= var.cum_cutoff and new_wikipedian != False:
39 - for year in xrange(new_wikipedian.year, final_edit):
40 - edits = editor['monthly_edits'].get(str(year), {0:0})
41 - if year == new_wikipedian.year:
42 - start = new_wikipedian.month
43 - else:
44 - start = 1
45 -
46 - for month in xrange(start, 13):
47 - if edits.get(str(month), 0) >= var.cutoff:
48 - day = calendar.monthrange(year, month)[1]
49 - dt = datetime.datetime(year, month, day)
50 - experience = relativedelta(dt, new_wikipedian)
51 - experience = experience.years * 12 + experience.months
52 - var.add(new_wikipedian, 1, {'experience': experience})
53 - return var
Index: trunk/tools/editor_trends/analyses/plugins/cohort_dataset_backward_bar.py
@@ -1,50 +0,0 @@
2 -#!/usr/bin/python
3 -# -*- coding: utf-8 -*-
4 -'''
5 -Copyright (C) 2010 by Diederik van Liere (dvanliere@gmail.com)
6 -This program is free software; you can redistribute it and/or
7 -modify it under the terms of the GNU General Public License version 2
8 -as published by the Free Software Foundation.
9 -This program is distributed in the hope that it will be useful,
10 -but WITHOUT ANY WARRANTY; without even the implied warranty of
11 -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 -See the GNU General Public License for more details, at
13 -http://www.fsf.org/licenses/gpl.html
14 -'''
15 -
16 -__author__ = '''\n'''.join(['Diederik van Liere (dvanliere@gmail.com)', ])
17 -__email__ = 'dvanliere at gmail dot com'
18 -__date__ = '2011-01-25'
19 -__version__ = '0.1'
20 -
21 -import datetime
22 -from dateutil.relativedelta import relativedelta
23 -from utils import data_converter
24 -
25 -
26 -def cohort_dataset_backward_bar(var, editor, **kwargs):
27 - '''
28 - The backward looking bar chart looks for every year that an editor
29 - was part of the Wikimedia community whether this person made at least cutoff
30 - value edits. If yes, then include this person in the analysis, else skip the
31 - person.
32 - '''
33 - break_down = kwargs.pop('break_down', False)
34 - new_wikipedian = editor['new_wikipedian']
35 - n = editor['edit_count']
36 -
37 - if n >= var.cum_cutoff and new_wikipedian != False:
38 - windows = data_converter.create_windows(var, break_down_first_year=break_down)
39 - for year in xrange(new_wikipedian.year, var.max_year):
40 - year = str(year)
41 - if editor['edits_by_year'][year] >= var.cutoff:
42 - last_edit = editor['last_edit_by_year'][year]
43 - if last_edit != 0.0:
44 - editor_dt = relativedelta(last_edit, new_wikipedian)
45 - editor_dt = (editor_dt.years * 12) + editor_dt.months
46 - for w in windows:
47 - if w >= editor_dt:
48 - datum = datetime.datetime(int(year), 12, 31)
49 - var.add(datum, 1, {'window':w})
50 - break
51 - return var
Index: trunk/tools/editor_trends/analyses/plugins/ets_cohort_forward_histogram.py
@@ -0,0 +1,57 @@
 2+#!/usr/bin/python
 3+# -*- coding: utf-8 -*-
 4+'''
 5+Copyright (C) 2010 by Diederik van Liere (dvanliere@gmail.com)
 6+This program is free software; you can redistribute it and/or
 7+modify it under the terms of the GNU General Public License version 2
 8+as published by the Free Software Foundation.
 9+This program is distributed in the hope that it will be useful,
 10+but WITHOUT ANY WARRANTY; without even the implied warranty of
 11+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 12+See the GNU General Public License for more details, at
 13+http://www.fsf.org/licenses/gpl.html
 14+'''
 15+
 16+__author__ = '''\n'''.join(['Diederik van Liere (dvanliere@gmail.com)', ])
 17+__email__ = 'dvanliere at gmail dot com'
 18+__date__ = '2011-01-25'
 19+__version__ = '0.1'
 20+
 21+import datetime
 22+from dateutil.relativedelta import *
 23+import calendar
 24+
 25+def cohort_dataset_forward_histogram(var, editor, **kwargs):
 26+ '''
 27+ The forward looking histogram looks for every month that an editor
 28+ was part of the Wikimedia community whether this person made at least cutoff
 29+ value edits. If yes, then include this person in the analysis, else skip the
 30+ person.
 31+ '''
 32+ new_wikipedian = editor['new_wikipedian']
 33+ n = editor['cum_edit_count']
 34+ edits = editor['edit_count']
 35+ #final_edit = editor['final_edit'].year + 1
 36+ #yearly_edits = editor['edits_by_year']
 37+
 38+
 39+ if n >= var.cum_cutoff and new_wikipedian != False:
 40+ years = edits.keys()
 41+ for year in years:
 42+ #edits = editor['monthly_edits'].get(str(year), {0:0})
 43+ #count = editor[year]
 44+ #if year == new_wikipedian.year:
 45+ # start = new_wikipedian.month
 46+ #else:
 47+ # start = 1
 48+ #for month in xrange(start, 13):
 49+ months = edits[year].keys()
 50+ for month in months:
 51+ if edits[year][month].get('0', 0) >= var.cutoff:
 52+ #if edits.get(str(month), 0) >= var.cutoff:
 53+ day = calendar.monthrange(int(year), int(month))[1]
 54+ dt = datetime.datetime(int(year), int(month), day)
 55+ experience = relativedelta(dt, new_wikipedian)
 56+ experience = experience.years * 12 + experience.months
 57+ var.add(new_wikipedian, 1, {'experience': experience})
 58+ return var
Property changes on: trunk/tools/editor_trends/analyses/plugins/ets_cohort_forward_histogram.py
___________________________________________________________________
Added: svn:eol-style
159 + native
Index: trunk/tools/editor_trends/analyses/plugins/ets_cohort_backward_bar.py
@@ -0,0 +1,51 @@
 2+#!/usr/bin/python
 3+# -*- coding: utf-8 -*-
 4+'''
 5+Copyright (C) 2010 by Diederik van Liere (dvanliere@gmail.com)
 6+This program is free software; you can redistribute it and/or
 7+modify it under the terms of the GNU General Public License version 2
 8+as published by the Free Software Foundation.
 9+This program is distributed in the hope that it will be useful,
 10+but WITHOUT ANY WARRANTY; without even the implied warranty of
 11+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 12+See the GNU General Public License for more details, at
 13+http://www.fsf.org/licenses/gpl.html
 14+'''
 15+
 16+__author__ = '''\n'''.join(['Diederik van Liere (dvanliere@gmail.com)', ])
 17+__email__ = 'dvanliere at gmail dot com'
 18+__date__ = '2011-01-25'
 19+__version__ = '0.1'
 20+
 21+import datetime
 22+from dateutil.relativedelta import relativedelta
 23+from utils import data_converter
 24+
 25+
 26+def cohort_dataset_backward_bar(var, editor, **kwargs):
 27+ '''
 28+ The backward looking bar chart looks for every year that an editor
 29+ was part of the Wikimedia community whether this person made at least cutoff
 30+ value edits. If yes, then include this person in the analysis, else skip the
 31+ person.
 32+ '''
 33+ break_down = kwargs.pop('break_down', False)
 34+ new_wikipedian = editor['new_wikipedian']
 35+ n = editor['cum_edit_count ']
 36+ edits = editor['edit_count']
 37+
 38+ if n >= var.cum_cutoff and new_wikipedian != False:
 39+ windows = data_converter.create_windows(var, break_down_first_year=break_down)
 40+ years = edits.keys()
 41+ for year in years:
 42+ if editor['totals']['edit_count'][year]['0'] >= var.cutoff:
 43+ last_edit = editor['last_edit_by_year'][year]
 44+ if last_edit != 0.0:
 45+ editor_dt = relativedelta(last_edit, new_wikipedian)
 46+ editor_dt = (editor_dt.years * 12) + editor_dt.months
 47+ for w in windows:
 48+ if w >= editor_dt:
 49+ datum = datetime.datetime(int(year), 12, 31)
 50+ var.add(datum, 1, {'window':w})
 51+ break
 52+ return var
Property changes on: trunk/tools/editor_trends/analyses/plugins/ets_cohort_backward_bar.py
___________________________________________________________________
Added: svn:eol-style
153 + native
Index: trunk/tools/editor_trends/analyses/plugins/ets_cohort_forward_bar.py
@@ -0,0 +1,47 @@
 2+#!/usr/bin/python
 3+# -*- coding: utf-8 -*-
 4+'''
 5+Copyright (C) 2010 by Diederik van Liere (dvanliere@gmail.com)
 6+This program is free software; you can redistribute it and/or
 7+modify it under the terms of the GNU General Public License version 2
 8+as published by the Free Software Foundation.
 9+This program is distributed in the hope that it will be useful,
 10+but WITHOUT ANY WARRANTY; without even the implied warranty of
 11+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 12+See the GNU General Public License for more details, at
 13+http://www.fsf.org/licenses/gpl.html
 14+'''
 15+
 16+__author__ = '''\n'''.join(['Diederik van Liere (dvanliere@gmail.com)', ])
 17+__email__ = 'dvanliere at gmail dot com'
 18+__date__ = '2011-01-25'
 19+__version__ = '0.1'
 20+
 21+
 22+def cohort_dataset_forward_bar(var, editor, **kwargs):
 23+ '''
 24+ The forward looking bar charts looks for every month that an editor
 25+ was part of the Wikimedia community whether this person made at least cutoff
 26+ value edits. If yes, then include this person in the analysis, else skip the
 27+ person.
 28+ '''
 29+ new_wikipedian = editor['new_wikipedian']
 30+ last_edit = editor['final_edit']
 31+ #monthly_edits = editor['monthly_edits']
 32+ #yearly_edits = editor['edits_by_year']
 33+ totals = editors['totals']['edit_count']
 34+ edits = editors['edit_count']
 35+ n = editor['cum_edit_count']
 36+
 37+ if n >= var.cum_cutoff and new_wikipedian != False:
 38+ years = edits.keys()
 39+ for year in years:
 40+ months = edits[year].keys()
 41+ max_edits = max([edits[year][month]['0'] for month in months])
 42+ #max_edits = max(monthly_edits.get(year, {0:0}).values())
 43+ if totals.get(year, 0) == 0 or max_edits < var.cutoff:
 44+ continue
 45+ else:
 46+ experience = (year - new_wikipedian.year) + 1
 47+ var.add(new_wikipedian, 1, {'experience':experience})
 48+ return var
Property changes on: trunk/tools/editor_trends/analyses/plugins/ets_cohort_forward_bar.py
___________________________________________________________________
Added: svn:eol-style
149 + native
Index: trunk/tools/editor_trends/analyses/plugins/ets_cohort_backward_histogram.py
@@ -0,0 +1,46 @@
 2+#!/usr/bin/python
 3+# -*- coding: utf-8 -*-
 4+'''
 5+Copyright (C) 2010 by Diederik van Liere (dvanliere@gmail.com)
 6+This program is free software; you can redistribute it and/or
 7+modify it under the terms of the GNU General Public License version 2
 8+as published by the Free Software Foundation.
 9+This program is distributed in the hope that it will be useful,
 10+but WITHOUT ANY WARRANTY; without even the implied warranty of
 11+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 12+See the GNU General Public License for more details, at
 13+http://www.fsf.org/licenses/gpl.html
 14+'''
 15+
 16+__author__ = '''\n'''.join(['Diederik van Liere (dvanliere@gmail.com)', ])
 17+__email__ = 'dvanliere at gmail dot com'
 18+__date__ = '2011-01-31'
 19+__version__ = '0.1'
 20+
 21+import datetime
 22+from dateutil.relativedelta import relativedelta
 23+from utils import data_converter
 24+
 25+def histogram_by_backward_cohort(var, editor, **kwargs):
 26+ break_down = kwargs.pop('break_down', False)
 27+ new_wikipedian = editor['new_wikipedian']
 28+ edits = editor['edit_count']
 29+ n = editor['cum_edit_count']
 30+
 31+ if n >= var.cum_cutoff and new_wikipedian != False:
 32+ windows = data_converter.create_windows(var, break_down_first_year=break_down)
 33+ years = edits.keys()
 34+ for year in years:
 35+ if editor['totals']['edit_count'][year].get('0', 0) >= var.cutoff:
 36+ last_edit = editor['last_edit_by_year'][year]
 37+ if last_edit != 0.0:
 38+ editor_dt = relativedelta(last_edit, new_wikipedian)
 39+ editor_dt = (editor_dt.years * 12) + editor_dt.months
 40+ for w in windows:
 41+ if w >= editor_dt:
 42+ date = datetime.datetime(int(year), 12, 31)
 43+ freq = editor['totals']['edit_count'][year].get('0', 0)
 44+ if freq > 0:
 45+ var.add(date, 1, {'window': w, 'frequency': freq})
 46+ break
 47+ return var
Property changes on: trunk/tools/editor_trends/analyses/plugins/ets_cohort_backward_histogram.py
___________________________________________________________________
Added: svn:eol-style
148 + native