Index: trunk/tools/editor_trends/analyses/plugins/taxonomy_list_makers.py |
— | — | @@ -17,27 +17,35 @@ |
18 | 18 | __date__ = '2011-01-25' |
19 | 19 | __version__ = '0.1' |
20 | 20 | |
| 21 | +import sys |
| 22 | + |
21 | 23 | def taxonomy_list_makers(var, editor, **kwargs): |
22 | 24 | """ |
23 | 25 | == List makers == |
24 | 26 | Any editor who makes more than 10 mainspace edits a month to articles with |
25 | 27 | titles that begin with "List of..." |
26 | 28 | """ |
27 | | - articles_by_year = editor['articles_by_year'] |
28 | | - count = 0 |
| 29 | + db_articles = kwargs.get('articles', None) |
29 | 30 | |
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) |
36 | 33 | |
| 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 |
37 | 46 | |
38 | 47 | """ Add all editors with an edit count of more than 10 """ |
39 | 48 | |
40 | 49 | if count > 10: |
41 | 50 | var.add(editor['username'], 1) |
42 | 51 | |
43 | | - |
44 | 52 | return var |
Index: trunk/tools/editor_trends/classes/analytics.py |
— | — | @@ -82,6 +82,7 @@ |
83 | 83 | project and then calls the plugin that does the actual mapping. |
84 | 84 | ''' |
85 | 85 | db = storage.Database('mongo', self.rts.dbname, self.rts.editors_dataset) |
| 86 | + articles = storage.Database('mongo', self.rts.dbname, self.rts.articles_raw) |
86 | 87 | while True: |
87 | 88 | try: |
88 | 89 | task = self.tasks.get(block=False) |
— | — | @@ -91,7 +92,7 @@ |
92 | 93 | break |
93 | 94 | editor = db.find_one('editor', task.editor) |
94 | 95 | |
95 | | - task.plugin(self.var, editor, dbname=self.rts.dbname) |
| 96 | + task.plugin(self.var, editor, dbname=self.rts.dbname, articles=articles) |
96 | 97 | self.result.put(True) |
97 | 98 | except Empty: |
98 | 99 | pass |