r85134 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r85133‎ | r85134 | r85135 >
Date:16:21, 1 April 2011
Author:diederik
Status:deferred
Tags:
Comment:
Final fixes to the dataprocessing chain.
Modified paths:
  • /trunk/tools/editor_trends/etl/store.py (modified) (history)
  • /trunk/tools/editor_trends/etl/transformer.py (modified) (history)

Diff [purge]

Index: trunk/tools/editor_trends/etl/store.py
@@ -117,13 +117,12 @@
118118 #print line.encode('utf-8')
119119 line = line.split('\t')
120120 data = {}
121 - for l in line:
122 - #print l.encode('utf-8')
123 - try:
124 - key, value = l.split('=')
125 - except ValueError, error:
126 - print l.encode('utf-8')
 121+ x, y = 0, 1
 122+ while y < len(line):
 123+ key, value = line[x], line[y]
127124 data[key] = value
 125+ x += 2
 126+ y += 2
128127 collection.insert(data)
129128 fh.close()
130129 print 'Done...'
Index: trunk/tools/editor_trends/etl/transformer.py
@@ -173,12 +173,14 @@
174174 for year in edits:
175175 for edit in edits[year]:
176176 month = edit['date'].month
177 - dc[year][month].setdefault('added', 0)
178 - dc[year][month].setdefault('removed', 0)
 177+ ns = edit['ns']
 178+ dc[year][month].setdefault(ns, {})
 179+ dc[year][month][ns].setdefault('added', 0)
 180+ dc[year][month][ns].setdefault('removed', 0)
179181 if edit['delta'] < 0:
180 - dc[year][month]['removed'] += edit['delta']
 182+ dc[year][month][ns]['removed'] += edit['delta']
181183 elif edit['delta'] > 0:
182 - dc[year][month]['added'] += edit['delta']
 184+ dc[year][month][ns]['added'] += edit['delta']
183185 return dc
184186
185187