Display correct number of active PRs

This commit is contained in:
Alexandre Aubin 2017-03-08 11:31:22 -05:00
parent a0dd6dabfd
commit b02e6e0ea0
3 changed files with 25 additions and 10 deletions

View file

@ -5,6 +5,12 @@ import datetime
prs = {}
def get_teams():
with open("repos.json", "r") as f:
return json.loads(f.read()).keys()
def get_repos():
repos_by_name = {}
@ -87,10 +93,17 @@ def main():
prs_sorted = sorted(prs.keys(), key=lambda x: (prs[x]["priority"],
prs[x]["createdDaysAgo"]), reverse=True )
summary = []
summary = {}
summary["teams"] = {}
summary["teams"]["all"] = len([pr for pr in prs.values() if pr["priority"] >= -50])
for team in get_teams():
summary["teams"][team] = len([pr for pr in prs.values()
if team in pr["teams"] and pr["priority"] >= -50])
summary["prs"] = []
for name in prs_sorted:
summary.append(prs[name])
summary["prs"].append(prs[name])
with open("summary.json", "w") as f:
f.write(json.dumps(summary))

View file

@ -30,14 +30,14 @@ if __name__ == '__main__':
# Fetch the list of all reports, sorted in reverse-chronological order
pr_list = json.load(open(summary_path))
summary = json.load(open(summary_path))
# Generate the output using the template
template = open(template_path, "r").read()
t = Template(template)
result = t.render(data=pr_list, convert=shell_to_html, shell_css=shell_css)
result = t.render(data=summary, convert=shell_to_html, shell_css=shell_css)
open(output_path, "w").write(result)

View file

@ -72,11 +72,13 @@
<div class="col-md-offset-3 col-md-6">
<div class="bs-component">
<ul class="nav nav-pills">
<li class="active"><a href="#">All <span class="badge">1664</span></a></li>
<li><a href="#">Core <span class="badge">42</span></a></li>
<li><a href="#">Apps <span class="badge">42</span></a/li>
<li><a href="#">Infra / dist<span class="badge">42</span></a></li>
<li><a href="#">Doc / i18n<span class="badge">42</span></a></li>
<li class="active">
<a href="#">All <span class="badge">{{ data.teams.all }}</span></a>
</li>
<li><a href="#">Core <span class="badge">{{ data.teams.core }}</span></a></li>
<li><a href="#">Apps <span class="badge">{{ data.teams.apps }}</span></a/li>
<li><a href="#">Infra / dist<span class="badge">{{ data.teams.infra }}</span></a></li>
<li><a href="#">Doc / i18n<span class="badge">{{ data.teams.doc }}</span></a></li>
</ul>
</div>
</div>
@ -96,7 +98,7 @@
</tr>
</thead>
<tbody>
{% for pr in data %}
{% for pr in data.prs %}
<tr>
<td><center><a class="btn
{% if pr.priority >= 100 %}btn-warning{% else %}