Mercurial > bitten > bitten-test
diff bitten/web_ui.py @ 756:3fbc7672640e
Charting fixes.
Only show charts on configuration pages where there's a report for the
chart's category in the range of active builds. Closes #454.
Restrict chart data to that of the active range of revisions. Closes #93.
author | wbell |
---|---|
date | Sat, 24 Apr 2010 13:52:13 +0000 |
parents | 7f698d867321 |
children | 306419d32527 |
line wrap: on
line diff
--- a/bitten/web_ui.py +++ b/bitten/web_ui.py @@ -13,6 +13,7 @@ import posixpath import re from StringIO import StringIO +from datetime import datetime import pkg_resources from genshi.builder import tag @@ -391,11 +392,13 @@ if has_reports: chart_generators = [] + report_categories = list(self._report_categories_for_config(config)) for generator in ReportChartController(self.env).generators: for category in generator.get_supported_categories(): - chart_generators.append({ - 'href': req.href.build(config.name, 'chart/' + category) - }) + if category in report_categories: + chart_generators.append({ + 'href': req.href.build(config.name, 'chart/' + category) + }) data['config']['charts'] = chart_generators charts_license = self.config.get('bitten', 'charts_license') if charts_license: @@ -450,6 +453,26 @@ prevnext_nav (req, 'Page') return data + def _report_categories_for_config(self, config): + """Yields the categories of reports that exist for active builds + of this configuration. + """ + + db = self.env.get_db_cnx() + repos = self.env.get_repository() + cursor = db.cursor() + + cursor.execute("""SELECT DISTINCT report.category as category +FROM bitten_build AS build +JOIN bitten_report AS report ON (report.build=build.id) +WHERE build.config=%s AND build.rev_time >= %s AND build.rev_time <= %s""", + (config.name, + config.min_rev_time(self.env), + config.max_rev_time(self.env))) + + for (category,) in cursor: + yield category + class BuildController(Component): """Renders the build page.""" @@ -672,10 +695,10 @@ if summarizer: tmpl, data = summarizer.render_summary(req, config, build, step, report.category) + reports.append({'category': report.category, + 'template': tmpl, 'data': data}) else: tmpl = data = None - reports.append({'category': report.category, - 'template': tmpl, 'data': data}) return reports