Rfaulk has uploaded a new change for review.
https://gerrit.wikimedia.org/r/59200
Change subject: fix. bug in revert_rate. Historics revs should be ordered by
descending rev_id.
......................................................................
fix. bug in revert_rate. Historics revs should be ordered by descending rev_id.
Change-Id: I2f243fea990faf8aa34696f66efc08b19606b082
---
M user_metrics/metrics/revert_rate.py
M user_metrics/query/query_calls_sql.py
2 files changed, 18 insertions(+), 7 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/analytics/E3Analysis
refs/changes/00/59200/1
diff --git a/user_metrics/metrics/revert_rate.py
b/user_metrics/metrics/revert_rate.py
index d2b0555..23fff70 100644
--- a/user_metrics/metrics/revert_rate.py
+++ b/user_metrics/metrics/revert_rate.py
@@ -102,13 +102,21 @@
def __revert(rev_id, page_id, sha1, user_text, metric_args):
""" Returns the revision corresponding to a revision if it exists. """
+
+ print 'current'
+ print str(rev_id) + ", " + str(sha1)
+
history = {}
+ print 'history'
for rev in __history(rev_id, page_id, metric_args.look_back,
metric_args.project, metric_args.namespace):
+ print str(rev[0]) + ", " + str(rev[RevertRate.REV_SHA1_IDX])
history[rev[RevertRate.REV_SHA1_IDX]] = rev
+ print 'future'
for rev in __future(rev_id, page_id, metric_args.look_ahead,
metric_args.project, metric_args.namespace):
+ print str(rev[0]) + ", " + str(rev[RevertRate.REV_SHA1_IDX])
if rev[RevertRate.REV_SHA1_IDX] in history and \
rev[RevertRate.REV_SHA1_IDX] != sha1:
if user_text == rev[RevertRate.REV_USER_TEXT_IDX]:
@@ -244,9 +252,7 @@
r = RevertRate()
users = ['17792132', '17797320', '17792130', '17792131', '17792136',
'17792137', '17792134', '17797328', '17797329', '17792138']
- for i in xrange(5):
- users += users
- for r in r.process(users,num_threads=50,rev_threads=50, log_progress=True):
+ for r in r.process(users, k_=1, kr_=1, log_=True):
print r
diff --git a/user_metrics/query/query_calls_sql.py
b/user_metrics/query/query_calls_sql.py
index 0a92b1f..4369f9d 100644
--- a/user_metrics/query/query_calls_sql.py
+++ b/user_metrics/query/query_calls_sql.py
@@ -25,6 +25,7 @@
WHERE_TOKEN = '<where>'
COMP1_TOKEN = '<comparator_1>'
USERS_TOKEN = '<users>'
+ORDER_TOKEN = '<order>'
class UMQueryCallError(Exception):
@@ -34,7 +35,7 @@
def sub_tokens(query, db='', table='', from_repl='', where='',
- comp_1='', users=''):
+ comp_1='', users='', order=''):
"""
Substitutes values for portions of queries that specify MySQL databases and
tables.
@@ -46,6 +47,7 @@
WHERE_TOKEN: where,
COMP1_TOKEN: comp_1,
USERS_TOKEN: users,
+ ORDER_TOKEN: order,
}
for token in tokens:
token_value = tokens[token]
@@ -287,10 +289,13 @@
# Format namespace expression and comparator
ns_cond = format_namespace(namespace)
+
comparator = '>' if look_ahead else '<'
+ order = 'ASC' if look_ahead else 'DESC'
+
query = query_store[page_rev_hist_query.__name__]
query = sub_tokens(query, db=escape_var(project),
- comp_1=comparator, where=ns_cond)
+ comp_1=comparator, where=ns_cond, order=order)
try:
params = {
'rev_id': long(rev_id),
@@ -755,13 +760,13 @@
WHERE rev_page = %(page_id)s
AND rev_id <comparator_1> %(rev_id)s
AND <where>
- ORDER BY rev_id ASC
+ ORDER BY rev_id <order>
LIMIT %(n)s
""",
revert_rate_user_revs_query.__query_name__:
"""
SELECT
- r.rev_user,
+ r.rev_id,
r.rev_page,
r.rev_sha1,
r.rev_user_text
--
To view, visit https://gerrit.wikimedia.org/r/59200
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I2f243fea990faf8aa34696f66efc08b19606b082
Gerrit-PatchSet: 1
Gerrit-Project: analytics/E3Analysis
Gerrit-Branch: master
Gerrit-Owner: Rfaulk <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits