[LNT] r226763 - Add JSON support for 'machine' and 'run' pages.
Michael Zolotukhin
mzolotukhin at apple.com
Wed Jan 21 17:59:31 PST 2015
Author: mzolotukhin
Date: Wed Jan 21 19:59:31 2015
New Revision: 226763
URL: http://llvm.org/viewvc/llvm-project?rev=226763&view=rev
Log:
Add JSON support for 'machine' and 'run' pages.
Include only the data available in usual HTML form.
Modified:
lnt/trunk/lnt/server/ui/views.py
lnt/trunk/tests/server/ui/V4Pages.py
Modified: lnt/trunk/lnt/server/ui/views.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/server/ui/views.py?rev=226763&r1=226762&r2=226763&view=diff
==============================================================================
--- lnt/trunk/lnt/server/ui/views.py (original)
+++ lnt/trunk/lnt/server/ui/views.py Wed Jan 21 19:59:31 2015
@@ -172,25 +172,18 @@ def v4_machine(id):
order_by(ts.Run.start_time.desc()))
associated_runs = associated_runs.items()
associated_runs.sort()
+
if request.args.get('json'):
json_obj = dict()
machine_obj = ts.query(ts.Machine).filter(ts.Machine.id == id).one()
json_obj['name'] = machine_obj.name
json_obj['id'] = machine_obj.id
- runs = {}
- tests = {}
- for sample in ts.query(ts.Sample).filter(ts.Run.machine_id == id).all():
- tests[sample.test.id] = sample.test.name
- runs[sample.run.id] = (sample.run.order.llvm_project_revision,
- sample.run.start_time,
- sample.run.end_time)
- json_obj['tests'] = []
- for test_id in tests:
- json_obj['tests'].append((test_id, tests[test_id]))
json_obj['runs'] = []
- for run_id in runs:
- (rev, start, end) = runs[run_id]
- json_obj['runs'].append((run_id, rev, start, end))
+ for order in associated_runs:
+ rev = order[0].llvm_project_revision
+ for run in order[1]:
+ json_obj['runs'].append((run.id, rev,
+ run.start_time, run.end_time))
return flask.jsonify(**json_obj)
return render_template("v4_machine.html",
@@ -366,6 +359,25 @@ def v4_run(id):
for test in test_info
if test_filter_re.search(test[0])]
+ if request.args.get('json'):
+ json_obj = dict()
+
+ sri = lnt.server.reporting.analysis.RunInfo(ts, [id])
+ reported_tests = ts.query(ts.Test.name, ts.Test.id).\
+ filter(ts.Run.id == id).\
+ filter(ts.Test.id.in_(sri.get_test_ids())).all()
+
+ json_obj['tests'] = {}
+ for test_name, test_id in reported_tests:
+ test = {}
+ test['name'] = test_name
+ for sample_field in ts.sample_fields:
+ res = sri.get_run_comparison_result(run, None, test_id, sample_field)
+ test[sample_field.name] = res.current
+ json_obj['tests'][test_id] = test
+
+ return flask.jsonify(**json_obj)
+
return render_template(
"v4_run.html", ts=ts, options=options,
primary_fields=list(ts.Sample.get_primary_fields()),
Modified: lnt/trunk/tests/server/ui/V4Pages.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/tests/server/ui/V4Pages.py?rev=226763&r1=226762&r2=226763&view=diff
==============================================================================
--- lnt/trunk/tests/server/ui/V4Pages.py (original)
+++ lnt/trunk/tests/server/ui/V4Pages.py Wed Jan 21 19:59:31 2015
@@ -50,6 +50,8 @@ def main():
# Get a run result page (and associated views).
check_code(client, '/v4/nts/1')
+ check_code(client, '/v4/nts/1?json=true')
+
check_code(client, '/v4/nts/1/report')
check_code(client, '/v4/nts/1/text_report')
More information about the llvm-commits
mailing list