[llvm-commits] [zorg] r151194 - in /zorg/trunk/lnt/lnt/server/ui: templates/v4_run.html views.py
Daniel Dunbar
daniel at zuster.org
Wed Feb 22 12:37:09 PST 2012
Author: ddunbar
Date: Wed Feb 22 14:37:09 2012
New Revision: 151194
URL: http://llvm.org/viewvc/llvm-project?rev=151194&view=rev
Log:
[lnt] lnt.server.ui.views/run overview: Factor out a V4RequestInfo helper object.
- This also makes text_report and html_report functions handle the compare_to request.
Modified:
zorg/trunk/lnt/lnt/server/ui/templates/v4_run.html
zorg/trunk/lnt/lnt/server/ui/views.py
Modified: zorg/trunk/lnt/lnt/server/ui/templates/v4_run.html
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/templates/v4_run.html?rev=151194&r1=151193&r2=151194&view=diff
==============================================================================
--- zorg/trunk/lnt/lnt/server/ui/templates/v4_run.html (original)
+++ zorg/trunk/lnt/lnt/server/ui/templates/v4_run.html Wed Feb 22 14:37:09 2012
@@ -1,6 +1,9 @@
{% import "v4_utils.html" as v4_utils %}
{% import "utils.html" as utils %}
+{% set run = request_info.run %}
+{% set compare_to = request_info.compare_to %}
+{% set ts = request_info.ts %}
{% set machine = run.machine %}
{% extends "layout.html" %}
@@ -72,8 +75,9 @@
{% endmacro %}
-{% call v4_utils.v4_run_page(ts, machine, run, compare_to, neighboring_runs,
- comparison_neighboring_runs) %}
+{% call v4_utils.v4_run_page(ts, machine, run, compare_to,
+ request_info.neighboring_runs,
+ request_info.comparison_neighboring_runs) %}
{{ utils.render_popup_begin('view_options', 'View Options', true) }}
<form action="" method="get">
@@ -139,12 +143,12 @@
{{ utils.render_popup_end() }}
{{ utils.render_popup_begin('text_report', 'Report (Text)', true) }}
-<pre>{{ text_report }}</pre>
+<pre>{{ request_info.text_report }}</pre>
{{ utils.render_popup_end() }}
{{ utils.render_popup_begin('html_report', 'Report (HTML)',
options.hide_report_by_default) }}
-{{html_report|safe}}
+{{request_info.html_report|safe}}
{{ utils.render_popup_end() }}
<h3>Tests</h3>
Modified: zorg/trunk/lnt/lnt/server/ui/views.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/server/ui/views.py?rev=151194&r1=151193&r2=151194&view=diff
==============================================================================
--- zorg/trunk/lnt/lnt/server/ui/views.py (original)
+++ zorg/trunk/lnt/lnt/server/ui/views.py Wed Feb 22 14:37:09 2012
@@ -747,71 +747,66 @@
testsuite_name=g.testsuite_name, id=id,
associated_runs=associated_runs)
+class V4RequestInfo(object):
+ def __init__(self, run_id, only_html_body=True):
+ self.db = request.get_db()
+ self.ts = ts = request.get_testsuite()
+ self.run = run = ts.query(ts.Run).filter_by(id=run_id).first()
+ if run is None:
+ abort(404)
+
+ # Find the neighboring runs, by order.
+ prev_runs = list(ts.get_previous_runs_on_machine(run, N = 3))
+ next_runs = list(ts.get_next_runs_on_machine(run, N = 3))
+ self.neighboring_runs = next_runs[::-1] + [self.run] + prev_runs
+
+ # Select the comparison run as either the previous run, or a user
+ # specified comparison run.
+ compare_to_str = request.args.get('compare_to')
+ if compare_to_str:
+ compare_to_id = int(compare_to_str)
+ self.compare_to = ts.query(ts.Run).\
+ filter_by(id=compare_to_id).first()
+ if self.compare_to is None:
+ # FIXME: Need better way to report this error.
+ abort(404)
+
+ self.comparison_neighboring_runs = (
+ list(ts.get_next_runs_on_machine(self.compare_to, N=3))[::-1] +
+ [self.compare_to] +
+ list(ts.get_previous_runs_on_machine(self.compare_to, N=3)))
+ else:
+ if prev_runs:
+ self.compare_to = prev_runs[0]
+ else:
+ self.compare_to = None
+ self.comparison_neighboring_runs = self.neighboring_runs
+
+ _, self.text_report, self.html_report = NTEmailReport.getReport(
+ result=None, db=self.db, run=self.run,
+ baseurl=db_url_for('index', _external=True),
+ was_added=True, will_commit=True, only_html_body=only_html_body,
+ compare_to=self.compare_to)
+
@v4_route("/<int:id>/report")
def v4_report(id):
- db = request.get_db()
- ts = request.get_testsuite()
- run = ts.query(ts.Run).filter_by(id=id).first()
- if run is None:
- abort(404)
-
- _, _, html_report = NTEmailReport.getReport(
- result=None, db=db, run=run,
- baseurl=db_url_for('index', _external=True),
- was_added=True, will_commit=True, only_html_body=False)
+ info = V4RequestInfo(id, only_html_body=False)
- return make_response(html_report)
+ return make_response(info.html_report)
@v4_route("/<int:id>/text_report")
def v4_text_report(id):
- db = request.get_db()
- ts = request.get_testsuite()
- run = ts.query(ts.Run).filter_by(id=id).first()
- if run is None:
- abort(404)
+ info = V4RequestInfo(id, only_html_body=False)
- _, text_report, _ = NTEmailReport.getReport(
- result=None, db=db, run=run,
- baseurl=db_url_for('index', _external=True),
- was_added=True, will_commit=True, only_html_body=True)
-
- response = make_response(text_report)
+ response = make_response(info.text_report)
response.mimetype = "text/plain"
return response
@v4_route("/<int:id>")
def v4_run(id):
- db = request.get_db()
- ts = request.get_testsuite()
- run = ts.query(ts.Run).filter_by(id=id).first()
- if run is None:
- abort(404)
-
- # Find the neighboring runs, by order.
- prev_runs = list(ts.get_previous_runs_on_machine(run, N = 3))
- next_runs = list(ts.get_next_runs_on_machine(run, N = 3))
- neighboring_runs = next_runs[::-1] + [run] + prev_runs
-
- # Select the comparison run as either the previous run, or a user specified
- # comparison run.
- compare_to_str = request.args.get('compare_to')
- if compare_to_str:
- compare_to_id = int(compare_to_str)
- compare_to = ts.query(ts.Run).filter_by(id = compare_to_id).first()
- if compare_to is None:
- return render_template("error.html", message="""\
-Invalid compare_to ID %r""" % compare_to_str)
-
- comparison_neighboring_runs = (
- list(ts.get_next_runs_on_machine(compare_to, N=3))[::-1] +
- [compare_to] +
- list(ts.get_previous_runs_on_machine(compare_to, N=3)))
- else:
- if prev_runs:
- compare_to = prev_runs[0]
- else:
- compare_to = None
- comparison_neighboring_runs = neighboring_runs
+ info = V4RequestInfo(id)
+ ts = info.ts
+ run = info.run
# Parse the view options.
options = {}
@@ -844,16 +839,6 @@
test_min_value_filter = float(test_min_value_filter_str)
else:
test_min_value_filter = 0.0
-
- # Generate the report for inclusion in the run page.
- #
- # FIXME: This is a crummy implementation of the concept that we want the
- # webapp UI to be easy to correlate with the email reports.
- _, text_report, html_report = NTEmailReport.getReport(
- result=None, db=db, run=run,
- baseurl=db_url_for('index', _external=True),
- was_added=True, will_commit=True, only_html_body=True,
- compare_to=compare_to)
# Gather the runs to use for statistical data.
comparison_window = list(ts.get_previous_runs_on_machine(
@@ -872,14 +857,12 @@
if test_filter_re.search(test[0])]
return render_template(
- "v4_run.html", ts=ts, run=run, compare_to=compare_to,
- options=options, neighboring_runs=neighboring_runs,
- comparison_neighboring_runs=comparison_neighboring_runs,
- text_report=text_report, html_report=html_report,
+ "v4_run.html", ts=ts, options=options,
primary_fields=list(ts.Sample.get_primary_fields()),
comparison_window=comparison_window,
sri=sri, test_info=test_info, runinfo=runinfo,
- test_min_value_filter=test_min_value_filter)
+ test_min_value_filter=test_min_value_filter,
+ request_info=info)
@v4_route("/order/<int:id>")
def v4_order(id):
More information about the llvm-commits
mailing list