| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Get stats about your activity. | 6 """Get stats about your activity. |
| 7 | 7 |
| 8 Example: | 8 Example: |
| 9 - my_activity.py for stats for the current week (last week on mondays). | 9 - my_activity.py for stats for the current week (last week on mondays). |
| 10 - my_activity.py -Q for stats for last quarter. | 10 - my_activity.py -Q for stats for last quarter. |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 'supports_owner_modified_query': False, | 111 'supports_owner_modified_query': False, |
| 112 'requires_auth': False, | 112 'requires_auth': False, |
| 113 'email_domain': 'chromium.org', | 113 'email_domain': 'chromium.org', |
| 114 }, | 114 }, |
| 115 ] | 115 ] |
| 116 | 116 |
| 117 gerrit_instances = [ | 117 gerrit_instances = [ |
| 118 { | 118 { |
| 119 'url': 'gerrit.chromium.org', | 119 'url': 'gerrit.chromium.org', |
| 120 'port': 29418, | 120 'port': 29418, |
| 121 'shorturl': 'crosreview.com', |
| 121 }, | 122 }, |
| 122 { | 123 { |
| 123 'url': 'gerrit-int.chromium.org', | 124 'url': 'gerrit-int.chromium.org', |
| 124 'port': 29419, | 125 'port': 29419, |
| 126 'shorturl': 'crosreview.com/i', |
| 125 }, | 127 }, |
| 126 ] | 128 ] |
| 127 | 129 |
| 128 google_code_projects = [ | 130 google_code_projects = [ |
| 129 { | 131 { |
| 130 'name': 'chromium', | 132 'name': 'chromium', |
| 131 'shorturl': 'crbug.com', | 133 'shorturl': 'crbug.com', |
| 132 }, | 134 }, |
| 133 { | 135 { |
| 134 'name': 'chromium-os', | 136 'name': 'chromium-os', |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 '--comments', | 389 '--comments', |
| 388 '--', | 390 '--', |
| 389 '-age:%ss' % str(max_age), | 391 '-age:%ss' % str(max_age), |
| 390 user_filter] | 392 user_filter] |
| 391 [stdout, _] = subprocess.Popen(gquery_cmd, stdout=subprocess.PIPE, | 393 [stdout, _] = subprocess.Popen(gquery_cmd, stdout=subprocess.PIPE, |
| 392 stderr=subprocess.PIPE).communicate() | 394 stderr=subprocess.PIPE).communicate() |
| 393 issues = str(stdout).split('\n')[:-2] | 395 issues = str(stdout).split('\n')[:-2] |
| 394 issues = map(json.loads, issues) | 396 issues = map(json.loads, issues) |
| 395 | 397 |
| 396 # TODO(cjhopman): should we filter abandoned changes? | 398 # TODO(cjhopman): should we filter abandoned changes? |
| 397 issues = map(self.process_gerrit_issue, issues) | 399 issues = [self.process_gerrit_issue(instance, issue) for issue in issues] |
| 398 issues = filter(self.filter_issue, issues) | 400 issues = filter(self.filter_issue, issues) |
| 399 issues = sorted(issues, key=lambda i: i['modified'], reverse=True) | 401 issues = sorted(issues, key=lambda i: i['modified'], reverse=True) |
| 400 | 402 |
| 401 return issues | 403 return issues |
| 402 | 404 |
| 403 def process_gerrit_issue(self, issue): | 405 def process_gerrit_issue(self, instance, issue): |
| 404 ret = {} | 406 ret = {} |
| 405 ret['review_url'] = issue['url'] | 407 ret['review_url'] = issue['url'] |
| 408 if 'shorturl' in instance: |
| 409 ret['review_url'] = 'http://%s/%s' % (instance['shorturl'], |
| 410 issue['number']) |
| 406 ret['header'] = issue['subject'] | 411 ret['header'] = issue['subject'] |
| 407 ret['owner'] = issue['owner']['email'] | 412 ret['owner'] = issue['owner']['email'] |
| 408 ret['author'] = ret['owner'] | 413 ret['author'] = ret['owner'] |
| 409 ret['created'] = datetime.fromtimestamp(issue['createdOn']) | 414 ret['created'] = datetime.fromtimestamp(issue['createdOn']) |
| 410 ret['modified'] = datetime.fromtimestamp(issue['lastUpdated']) | 415 ret['modified'] = datetime.fromtimestamp(issue['lastUpdated']) |
| 411 if 'comments' in issue: | 416 if 'comments' in issue: |
| 412 ret['replies'] = self.process_gerrit_issue_replies(issue['comments']) | 417 ret['replies'] = self.process_gerrit_issue_replies(issue['comments']) |
| 413 else: | 418 else: |
| 414 ret['replies'] = [] | 419 ret['replies'] = [] |
| 415 ret['reviewers'] = set() | 420 ret['reviewers'] = set() |
| (...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1020 print '\n\n\n' | 1025 print '\n\n\n' |
| 1021 | 1026 |
| 1022 my_activity.print_changes() | 1027 my_activity.print_changes() |
| 1023 my_activity.print_reviews() | 1028 my_activity.print_reviews() |
| 1024 my_activity.print_issues() | 1029 my_activity.print_issues() |
| 1025 return 0 | 1030 return 0 |
| 1026 | 1031 |
| 1027 | 1032 |
| 1028 if __name__ == '__main__': | 1033 if __name__ == '__main__': |
| 1029 sys.exit(main()) | 1034 sys.exit(main()) |
| OLD | NEW |