Commit 4aedec01 authored by Andrii Shyshkalov's avatar Andrii Shyshkalov Committed by Commit Bot

my_activity: faster Gerrit reviews search.

Test: verified the same reviews list is produced w/o and w/ this change.
Change-Id: I72be85734a84d96a06b74515e64344fc203b1eed
Reviewed-on: https://chromium-review.googlesource.com/1227442Reviewed-by: 's avatarSergiy Byelozyorov <sergiyb@chromium.org>
Commit-Queue: Andrii Shyshkalov <tandrii@chromium.org>
parent 2174136d
......@@ -372,9 +372,12 @@ class MyActivity(object):
def gerrit_search(self, instance, owner=None, reviewer=None):
max_age = datetime.today() - self.modified_after
max_age = max_age.days * 24 * 3600 + max_age.seconds
user_filter = 'owner:%s' % owner if owner else 'reviewer:%s' % reviewer
filters = ['-age:%ss' % max_age, user_filter]
filters = ['-age:%ss' % (max_age.days * 24 * 3600 + max_age.seconds)]
if owner:
assert not reviewer
filters.append('owner:%s' % owner)
else:
filters.extend(('-owner:%s' % reviewer, 'reviewer:%s' % reviewer))
# TODO(cjhopman): Should abandoned changes be filtered out when
# merged_only is not enabled?
if self.options.merged_only:
......@@ -697,7 +700,6 @@ class MyActivity(object):
gerrit_instances)
rietveld_reviews = itertools.chain.from_iterable(rietveld_reviews.get())
gerrit_reviews = itertools.chain.from_iterable(gerrit_reviews.get())
gerrit_reviews = [r for r in gerrit_reviews if not self.match(r['owner'])]
self.reviews = list(rietveld_reviews) + list(gerrit_reviews)
def print_reviews(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment