Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(87)

Side by Side Diff: my_reviews.py

Issue 7977030: Add my_reviews.py script for perf time. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: another comment Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | rietveld.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 """Get rietveld stats.
7
8 Example:
9 - my_reviews.py -o me@chromium.org -Q for stats for last quarter.
10 """
11 import datetime
12 import optparse
13 import os
14 import sys
15
16 import rietveld
17
18
19 def print_reviews(owner, reviewer, created_after, created_before):
20 """Prints issues with the filter.
21
22 Set with_messages=True to search() call bellow if you want each message too.
23 If you only want issue numbers, use keys_only=True in the search() call.
24 You can then use remote.get_issue_properties(issue, True) to get the data per
25 issue.
26 """
27 instance_url = 'codereview.chromium.org'
28 remote = rietveld.Rietveld(instance_url, None, None)
29
30 # See def search() in rietveld.py to see all the filters you can use.
31 for issue in remote.search(
32 owner=owner,
33 reviewer=reviewer,
34 created_after=created_after,
35 created_before=created_before,
36 keys_only=False,
37 with_messages=False,
38 ):
39 # By default, hide commit-bot and the domain.
40 reviewers = set(r.split('@', 1)[0] for r in issue['reviewers'])
41 reviewers -= set(('commit-bot',))
42 # Strip time.
43 timestamp = issue['created'][:10]
44
45 # More information is available, print issue.keys() to see them.
46 print '%d: %s %s' % (issue['issue'], timestamp, ', '.join(reviewers))
47
48
49 def get_previous_quarter(today):
50 """There are four quarters, 01-03, 04-06, 07-09, 10-12.
51
52 If today is in the last month of a quarter, assume it's the current quarter
53 that is requested.
54 """
55 year = today.year
56 month = today.month - (today.month % 3)
57 if not month:
58 month = 12
59 year -= 1
60 previous_month = month - 2
61 return (
62 '%d-%02d-01' % (year, previous_month),
63 '%d-%02d-01' % (year, month))
64
65
66 def main():
67 parser = optparse.OptionParser(description=sys.modules[__name__].__doc__)
68 parser.add_option('-o', '--owner')
69 parser.add_option('-r', '--reviewer')
70 parser.add_option('-c', '--created_after')
71 parser.add_option('-C', '--created_before')
72 parser.add_option('-Q', '--last_quarter', action='store_true')
73 # Remove description formatting
74 parser.format_description = lambda x: parser.description
75 options, args = parser.parse_args()
76 if args:
77 parser.error('Args unsupported')
78 if not options.owner and not options.reviewer:
79 options.owner = os.environ['EMAIL_ADDRESS']
80 if '@' not in options.owner:
81 parser.error('Please specify at least -o or -r')
82 print 'Defaulting to owner=%s' % options.owner
83 if options.last_quarter:
84 today = datetime.date.today()
85 options.created_after, options.created_before = get_previous_quarter(today)
86 print 'Using range %s to %s' % (
87 options.created_after, options.created_before)
88 print_reviews(
89 options.owner, options.reviewer,
90 options.created_after, options.created_before)
91 return 0
92
93
94 if __name__ == '__main__':
95 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | rietveld.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698