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

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: Address review comments 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 add with_messages=True to search() call above if you want messages too.
23 If you only want numbers, use keys_only=True in the search() call above.
24 You can 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 for issue in remote.search(
30 owner=owner,
31 reviewer=reviewer,
32 created_after=created_after,
33 created_before=created_before,
34 keys_only=False,
35 with_messages=False,
36 ):
37 # By default, hide commit-bot and the domain.
38 reviewers = set(r.split('@', 1)[0] for r in issue['reviewers'])
39 reviewers -= set(('commit-bot',))
40
41 # FYI, available bits of data are:
42 # 'base_url'
43 # 'cc'
44 # 'closed'
45 # 'commit'
46 # 'created'
47 # 'description'
48 # 'issue'
49 # 'modified'
50 # 'owner'
51 # 'owner_email'
52 # 'patchsets'
53 # 'private'
54 # 'reviewers'
55 # 'subject'
Dirk Pranke 2011/09/21 21:05:42 I think I wasn't clear. You list the "available bi
56
57 # Strip time.
58 timestamp = issue['created'][:10]
59 print '%d: %s %s' % (issue['issue'], timestamp, ', '.join(reviewers))
60
61
62 def get_previous_quarter(today):
63 """There are four quarters, 01-03, 04-06, 07-09, 10-12.
64
65 If today is in the last month of a quarter, assume it's the current quarter
66 that is requested.
67 """
68 year = today.year
69 month = today.month - (today.month % 3)
70 if not month:
71 month = 12
72 year -= 1
73 previous_month = month - 2
74 return (
75 '%d-%02d-01' % (year, previous_month),
76 '%d-%02d-01' % (year, month))
77
78
79 def main():
80 parser = optparse.OptionParser(description=sys.modules[__name__].__doc__)
81 parser.add_option('-o', '--owner')
82 parser.add_option('-r', '--reviewer')
83 parser.add_option('-c', '--created_after')
84 parser.add_option('-C', '--created_before')
85 parser.add_option('-Q', '--last_quarter', action='store_true')
86 # Remove description formatting
87 parser.format_description = lambda x: parser.description
88 options, args = parser.parse_args()
89 if args:
90 parser.error('Args unsupported')
91 if not options.owner and not options.reviewer:
92 options.owner = os.environ['EMAIL_ADDRESS']
93 if '@' not in options.owner:
94 parser.error('Please specify at least -o or -r')
95 print 'Defaulting to owner=%s' % options.owner
96 if options.last_quarter:
97 today = datetime.date.today()
98 options.created_after, options.created_before = get_previous_quarter(today)
99 print 'Using range %s to %s' % (
100 options.created_after, options.created_before)
101 print_reviews(
102 options.owner, options.reviewer,
103 options.created_after, options.created_before)
104 return 0
105
106
107 if __name__ == '__main__':
108 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