r85641 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r85640‎ | r85641 | r85642 >
Date:21:32, 7 April 2011
Author:diederik
Status:deferred
Tags:
Comment:
The articles collection is now searchable from a plugin as well. The taxonomy_list_makers plugin is updated accordingly.
Modified paths:
  • /trunk/tools/editor_trends/analyses/plugins/taxonomy_list_makers.py (modified) (history)
  • /trunk/tools/editor_trends/classes/analytics.py (modified) (history)

Diff [purge]

Index: trunk/tools/editor_trends/analyses/plugins/taxonomy_list_makers.py
@@ -17,27 +17,35 @@
1818 __date__ = '2011-01-25'
1919 __version__ = '0.1'
2020
 21+import sys
 22+
2123 def taxonomy_list_makers(var, editor, **kwargs):
2224 """
2325 == List makers ==
2426 Any editor who makes more than 10 mainspace edits a month to articles with
2527 titles that begin with "List of..."
2628 """
27 - articles_by_year = editor['articles_by_year']
28 - count = 0
 29+ db_articles = kwargs.get('articles', None)
2930
30 - for year in xrange(new_wikipedian.year, var.max_year):
31 - for month in xrange(1, 13):
32 - for article in articles_by_year[year][month]:
33 - """ locate article titles containing "List of" """
34 - if article.find('List of') > -1:
35 - count = count + 1
 31+ if db_articles == None:
 32+ sys.exit(-1)
3633
 34+ articles_edited = editor['articles_edited']
 35+ count = 0
 36+ years = articles_edited.keys()
 37+ for year in years:
 38+ months = articles_edited[year].keys()
 39+ for month in months:
 40+ articles = articles_edited[year].get(month, [])
 41+ for article in articles:
 42+ article = db_articles.find('id', article)
 43+ print article
 44+ if article['category'] == 'List':
 45+ count += 1
3746
3847 """ Add all editors with an edit count of more than 10 """
3948
4049 if count > 10:
4150 var.add(editor['username'], 1)
4251
43 -
4452 return var
Index: trunk/tools/editor_trends/classes/analytics.py
@@ -82,6 +82,7 @@
8383 project and then calls the plugin that does the actual mapping.
8484 '''
8585 db = storage.Database('mongo', self.rts.dbname, self.rts.editors_dataset)
 86+ articles = storage.Database('mongo', self.rts.dbname, self.rts.articles_raw)
8687 while True:
8788 try:
8889 task = self.tasks.get(block=False)
@@ -91,7 +92,7 @@
9293 break
9394 editor = db.find_one('editor', task.editor)
9495
95 - task.plugin(self.var, editor, dbname=self.rts.dbname)
 96+ task.plugin(self.var, editor, dbname=self.rts.dbname, articles=articles)
9697 self.result.put(True)
9798 except Empty:
9899 pass