r109505 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r109504‎ | r109505 | r109506 >
Date:06:13, 19 January 2012
Author:diederik
Status:resolved (Comments)
Tags:
Comment:
Update
Modified paths:
  • /trunk/tools/editor_trends/analyses/adhoc/taxonomy_deletion.py (added) (history)
  • /trunk/tools/editor_trends/analyses/plugins/ppi_editor_productivity.py (modified) (history)

Diff [purge]

Index: trunk/tools/editor_trends/analyses/plugins/ppi_editor_productivity.py
@@ -29,15 +29,28 @@
3030
3131 edits = editor['character_count']
3232 username = editor['username']
 33+<<<<<<< .mine
 34+
 35+=======
 36+>>>>>>> .r88955
3337 try:
3438 added = edits['2010']['11']['0']['added']
3539 except KeyError:
 40+<<<<<<< .mine
3641 added = 0
3742 try:
3843 removed = edits['2010']['11']['0']['removed']
3944 except KeyError:
4045 removed = 0
4146
 47+=======
 48+ added = 0
 49+ try:
 50+ removed = edits['2010']['11']['0']['removed']
 51+ except KeyError:
 52+ removed = 0
 53+>>>>>>> .r88955
 54+
4255 key = datetime(2010, 11, 30)
4356 if added > 0:
4457 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+

Comments

#Comment by Siebrand (talk | contribs)   10:33, 19 January 2012

Contains a merge conflict.

#Comment by Drdee (talk | contribs)   19:03, 23 January 2012

Rev. 109842 fixes this.

Status & tagging log