Index: trunk/tools/editor_trends/analyses/plugins/ppi_editor_productivity.py |
— | — | @@ -29,15 +29,28 @@ |
30 | 30 | |
31 | 31 | edits = editor['character_count'] |
32 | 32 | username = editor['username'] |
| 33 | +<<<<<<< .mine |
| 34 | + |
| 35 | +======= |
| 36 | +>>>>>>> .r88955 |
33 | 37 | try: |
34 | 38 | added = edits['2010']['11']['0']['added'] |
35 | 39 | except KeyError: |
| 40 | +<<<<<<< .mine |
36 | 41 | added = 0 |
37 | 42 | try: |
38 | 43 | removed = edits['2010']['11']['0']['removed'] |
39 | 44 | except KeyError: |
40 | 45 | removed = 0 |
41 | 46 | |
| 47 | +======= |
| 48 | + added = 0 |
| 49 | + try: |
| 50 | + removed = edits['2010']['11']['0']['removed'] |
| 51 | + except KeyError: |
| 52 | + removed = 0 |
| 53 | +>>>>>>> .r88955 |
| 54 | + |
42 | 55 | key = datetime(2010, 11, 30) |
43 | 56 | if added > 0: |
44 | 57 | var.add(key, added, {'username': username, 'added': 'added'}) |
Index: trunk/tools/editor_trends/analyses/adhoc/taxonomy_deletion.py |
— | — | @@ -0,0 +1,45 @@ |
| 2 | +import pymongo |
| 3 | +import codecs |
| 4 | +from pymongo.master_slave_connection import MasterSlaveConnection |
| 5 | + |
| 6 | +master = pymongo.Connection('alpha') |
| 7 | +slaves = [pymongo.Connection('beta')] |
| 8 | +conn = MasterSlaveConnection(master, slaves) |
| 9 | +db = conn['wikilytics'] |
| 10 | + |
| 11 | +articles = set() |
| 12 | +namespaces = ['4','5'] |
| 13 | +editors_found=[] |
| 14 | + |
| 15 | +cursor = db.enwiki_articles_dataset.find({'category': 'Deletion'}) |
| 16 | +for article in cursor: |
| 17 | + articles.add(article['id']) |
| 18 | + |
| 19 | +cursor = db.enwiki_editors_dataset.find() |
| 20 | + |
| 21 | +fh = codecs.open('taxonomy_deletion', 'w', 'utf-8') |
| 22 | + |
| 23 | +for editor in cursor: |
| 24 | + articles_edited = editor.get('articles_edited', {}) |
| 25 | + years = articles_edited.keys() |
| 26 | + username = editor['username'] |
| 27 | + for year in years: |
| 28 | + months = articles_edited[year].keys() |
| 29 | + for month in months: |
| 30 | + for ns in namespaces: |
| 31 | + articles_list = articles_edited[year][month].get(ns, []) |
| 32 | + arts = set() |
| 33 | + for article in articles_list: |
| 34 | + arts.add(article) |
| 35 | + deletion_articles = articles.intersection(arts) |
| 36 | + if len(deletion_articles) > 10 and editor['editor'] not in editors_found: |
| 37 | + time = '%s-%s' % (year, month) |
| 38 | + #if type(username) == type(str()): |
| 39 | + # usename = username.decode('utf-8') |
| 40 | + #elif type(username) == type(unicode()): |
| 41 | + # usename = username.encode('utf-8') |
| 42 | + #print '%s\t%s\t%s\t%s' % (username, editor['editor'],time, len(deletion_articles)) |
| 43 | + fh.write('%s\t%s\t%s\t%s\n' % (username, editor['editor'],time, len(deletion_articles))) |
| 44 | + editors_found.append(editor['editor']) |
| 45 | +fh.close() |
| 46 | + |