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

Side by Side Diff: infra/tools/antibody/antibody.py

Issue 1235373004: Added script to generate stats on a git checkout (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@new_antibody_db_schema
Patch Set: Fixed nits and changed output for antibody stats Created 5 years, 5 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
OLDNEW
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Testable functions for Antibody.""" 5 """Testable functions for Antibody."""
6 6
7 import jinja2 7 import jinja2
8 import json 8 import json
9 import logging 9 import logging
10 import os 10 import os
11 import shutil 11 import shutil
12 12
13 import infra.tools.antibody.cloudsql_connect as csql 13 import infra.tools.antibody.cloudsql_connect as csql
14 from infra.tools.antibody import compute_stats
14 15
15 THIS_DIR = os.path.dirname(os.path.realpath(__file__)) 16 THIS_DIR = os.path.dirname(os.path.realpath(__file__))
16 ANTIBODY_UI_MAIN_NAME = 'index.html' 17 ANTIBODY_UI_MAIN_NAME = 'index.html'
17 TBR_BY_USER_NAME = 'tbr_by_user.html' 18 TBR_BY_USER_NAME = 'tbr_by_user.html'
18 19
19 # https://storage.googleapis.com/chromium-infra-docs/infra/html/logging.html 20 # https://storage.googleapis.com/chromium-infra-docs/infra/html/logging.html
20 LOGGER = logging.getLogger(__name__) 21 LOGGER = logging.getLogger(__name__)
21 22
22 23
23 def add_argparse_options(parser): 24 def add_argparse_options(parser):
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 101
101 102
102 def get_gitiles_prefix(git_checkout_path): 103 def get_gitiles_prefix(git_checkout_path):
103 with open(os.path.join(git_checkout_path, 'codereview.settings'), 'r') as f: 104 with open(os.path.join(git_checkout_path, 'codereview.settings'), 'r') as f:
104 lines = f.readlines() 105 lines = f.readlines()
105 for line in lines: 106 for line in lines:
106 if line.startswith('VIEW_VC:'): 107 if line.startswith('VIEW_VC:'):
107 return line[len('VIEW_VC:'):].strip() 108 return line[len('VIEW_VC:'):].strip()
108 # TODO (ksho): implement more sophisticated solution if codereview.settings 109 # TODO (ksho): implement more sophisticated solution if codereview.settings
109 # does not contain VIEW_VC 110 # does not contain VIEW_VC
110 return None 111 return None
112
113
114 def generate_stats_files(cc, output_dirpath):
115 compute_stats.all_time_leaderboard(cc,
116 os.path.join(output_dirpath, 'all_time_leaderboard'))
117 compute_stats.past_month_leaderboard(cc,
118 os.path.join(output_dirpath, 'past_month_leaderboard'))
119 compute_stats.all_monthly_stats(cc,
120 os.path.join(output_dirpath, 'all_monthly_stats'))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698