r110820 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r110819‎ | r110820 | r110821 >
Date:02:29, 7 February 2012
Author:rfaulk
Status:deferred
Tags:nodeploy, tools 
Comment:
Added logic to break out edit activity by: 0-3 days, 3-30 days, and more than 30 days after template posting event
Modified paths:
  • /trunk/tools/wsor/message_templates/umetrics/generators/edit_counts.py (modified) (history)

Diff [purge]

Index: trunk/tools/wsor/message_templates/umetrics/generators/edit_counts.py
@@ -1,4 +1,4 @@
2 -import itertools
 2+import itertools, datetime, time
33 from .metric_generator import MetricGenerator
44
55 class EditCounts(MetricGenerator):
@@ -10,9 +10,13 @@
1111 return itertools.chain(*[
1212 [
1313 'ns_%s_revisions_before' % ns,
14 - 'ns_%s_revisions_after' % ns,
 14+ 'ns_%s_revisions_after_0_3' % ns,
 15+ 'ns_%s_revisions_after_3_30' % ns,
 16+ 'ns_%s_revisions_after_gt_30' % ns,
1517 'ns_%s_revisions_deleted_before' % ns,
16 - 'ns_%s_revisions_deleted_after' % ns
 18+ 'ns_%s_revisions_deleted_after_0_3' % ns,
 19+ 'ns_%s_revisions_deleted_after_3_30' % ns,
 20+ 'ns_%s_revisions_deleted_after_gt_30' % ns
1721 ]
1822 for ns in [0,3]
1923 # for ns in itertools.chain(range(0,16), [100, 101, 108, 109])
@@ -21,12 +25,26 @@
2226 def values(self, username, timestamp):
2327 rowData = {}
2428
 29+ # Partition timestamps into:
 30+ #
 31+ # 0-3 days after
 32+ # 3-30 days after
 33+ # more than 30 days after
 34+
 35+ timeobj = datetime.datetime(year=int(timestamp[:4]), month=int(timestamp[4:6]), day=int(timestamp[6:8]), hour=int(timestamp[8:10]), minute=int(timestamp[10:12]), second=int(timestamp[12:14]))
 36+
 37+ timeobj_3_days = timeobj + datetime.timedelta(days=3)
 38+ timeobj_30_days = timeobj + datetime.timedelta(days=30)
 39+
 40+ timestamp_3_days = time.strftime("%Y%m%d%H%M%S", timeobj_3_days.timetuple())
 41+ timestamp_30_days = time.strftime("%Y%m%d%H%M%S", timeobj_30_days.timetuple())
 42+
2543 cursor = self.conn.cursor()
2644 cursor.execute("""
2745 (
2846 SELECT
2947 page_namespace as ns,
30 - IF(rev_timestamp < %(timestamp)s, "before", "after") as whence,
 48+ IF(rev_timestamp < %(timestamp)s, "before", IF(rev_timestamp < %(timestamp_3_days)s, "after_0_3", IF(rev_timestamp < %(timestamp_30_days)s, "after_3_30", "after_gt_30"))) as whence,
3149 "" as deleted,
3250 count(*) as revisions
3351 FROM enwiki.revision
@@ -37,7 +55,7 @@
3856 UNION (
3957 SELECT
4058 ar_namespace as ns,
41 - IF(ar_timestamp < %(timestamp)s, "before", "after") as whence,
 59+ IF(ar_timestamp < %(timestamp)s, "before", IF(ar_timestamp < %(timestamp_3_days)s, "after_0_3", IF(ar_timestamp < %(timestamp_30_days)s, "after_3_30", "after_gt_30"))) as whence,
4260 "_deleted" as deleted,
4361 count(*) as revisions
4462 FROM enwiki.archive
@@ -46,6 +64,8 @@
4765 )""",
4866 {
4967 'timestamp': timestamp,
 68+ 'timestamp_3_days': timestamp_3_days,
 69+ 'timestamp_30_days': timestamp_30_days,
5070 'username': username.encode('utf-8')
5171 }
5272 )

Status & tagging log