diff --git a/generate.py b/generate.py index 186aba35..4ba63b32 100755 --- a/generate.py +++ b/generate.py @@ -62,7 +62,7 @@ class Issue: return self.title @classmethod - def load_issues(cls, title_alias_map): + def load_issues(cls, title_alias_map, title_lookup): """ Search through all GitHub issues for any title tags to construct a list of titles and their associated issues @@ -75,8 +75,14 @@ class Issue: # Look for a titles sequence and pull out anything that looks like # an id references = ' '.join(titles_re.findall(issue.body or '')) - affected_titles = title_id_re.findall(references) - cls.all_issues.append(cls( + affected_titles = set() + for title_id in title_id_re.findall(references): + if title_id not in title_alias_map: + print('Warning: Issue %s references unknown title id "%s"' % (issue.url, title_id)) + continue + affected_titles.add(title_lookup[title_alias_map[title_id]]) + + issue = cls( issue.number, issue.html_url, issue.title, @@ -84,16 +90,17 @@ class Issue: issue.created_at.replace(tzinfo=timezone.utc), issue.updated_at.replace(tzinfo=timezone.utc), issue.closed_at.replace(tzinfo=timezone.utc) if issue.state == 'closed' else None, - issue.state)) + issue.state) - # Organize issues by title - for issue in cls.all_issues: - for title_id in issue.affected_titles: - if title_id not in title_alias_map: - print('Warning: Issue %s references unknown title id "%s"' % (issue.url, title_id)) - continue - if issue not in cls.issues_by_title[title_alias_map[title_id]]: - cls.issues_by_title[title_alias_map[title_id]].append(issue) + cls.all_issues.append(issue) + + for title in issue.affected_titles: + if issue not in cls.issues_by_title[title.info['title_id']]: + cls.issues_by_title[title.info['title_id']].append(issue) + + @property + def blocked_titles(self): + return {t for t in self.affected_titles if t.status in {'Broken', 'Intro', 'Starts'}} class CompatibilityReport: @@ -248,7 +255,7 @@ def main(): print(' - Found %d' % (len(titles))) print('Getting GitHub Issues List...') - Issue.load_issues(title_alias_map) + Issue.load_issues(title_alias_map, title_lookup) print(' - Ok. %d issues total' % len(Issue.all_issues)) print('Getting compatibility report list...') @@ -344,6 +351,20 @@ def main(): minify_js=True, minify_css=True)) print(' - Ok') + print('Building top issues table') + issues_by_num_affected = [i for i in Issue.all_issues if i.state != 'closed' and i.affected_titles] + issues_by_num_affected.sort(key=lambda i: len(i.affected_titles), reverse=True) + issues_by_num_blocking = [i for i in issues_by_num_affected if len(i.blocked_titles)] + issues_by_num_blocking.sort(key=lambda i: len(i.blocked_titles), reverse=True) + + template = env.get_template('top_issues.html') + with open(os.path.join(output_dir, 'top_issues.html'), 'w') as f: + f.write( + minify_html( + template.render(issues_by_num_affected=issues_by_num_affected, issues_by_num_blocking=issues_by_num_blocking), + minify_js=True, minify_css=True)) + print(' - Ok') + print('Updating download.md with latest build version') with open('docs/docs/download.md', 'r', encoding='utf-8') as f: t = f.read() diff --git a/templates/top_issues.html b/templates/top_issues.html new file mode 100644 index 00000000..9119fd98 --- /dev/null +++ b/templates/top_issues.html @@ -0,0 +1,63 @@ +{% extends "template_base.html" %} +{% block title %}Top Issues{% endblock %} + +{% block append_head %} + + +{% endblock %} + +{% block content %} +
+

Top Blocking Issues

+

+ The following lists top issues by blocked titles. +

+
+ + + + + + + + + + + {% for issue in issues_by_num_blocking %} + + + + + + {% endfor %} + +
TitleBlocked TitlesAffected Titles
#{{ issue.number }}: {{ issue.title|e }}{{ issue.blocked_titles|length }}{{ issue.affected_titles|length }}
+ +
+

Top Issues

+

+ The following lists top issues by affected titles. +

+
+ + + + + + + + + + {% for issue in issues_by_num_affected %} + + + + + {% endfor %} + +
TitleAffected Titles
#{{ issue.number }}: {{ issue.title|e }}{{ issue.affected_titles|length }}
+{% endblock %}