[LNT] Add json support to machine overview page

Chris Matthews chris.matthews at apple.com
Tue Dec 9 14:38:00 PST 2014


I think the query to add runs and tests needs to be joined to get only runs and tests referenced from this machine.  Also append the test and run IDs to the json object.

> On Dec 8, 2014, at 3:25 PM, Michael Zolotukhin <mzolotukhin at apple.com> wrote:
> 
> Hi,
> 
> This patch adds JSON-format for machine-overview page. Does it look good?
> 
> Thanks,
> Michael
> 
> Index: lnt/server/ui/views.py
> ===================================================================
> --- lnt/server/ui/views.py	(revision 223085)
> +++ lnt/server/ui/views.py	(working copy)
> @@ -172,6 +172,20 @@
>              order_by(ts.Run.start_time.desc()))
>      associated_runs = associated_runs.items()
>      associated_runs.sort()
> +    if bool(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
> +        json_obj['runs'] = []
> +        for t in ts.query(ts.Run):
> +            json_obj['runs'].append((t.order.llvm_project_revision,
> +                                     t.start_time,
> +                                     t.end_time))
> +        json_obj['tests'] = []
> +        for test in ts.query(ts.Test).all():
> +            json_obj['tests'].append((test.name, test.id))
> +        return flask.jsonify(**json_obj)
> 
>      return render_template("v4_machine.html",
>                             testsuite_name=g.testsuite_name, id=id,
> Index: tests/server/ui/V4Pages.py
> ===================================================================
> --- tests/server/ui/V4Pages.py	(revision 223085)
> +++ tests/server/ui/V4Pages.py	(working copy)
> @@ -38,6 +38,9 @@
>      # Get a machine overview page.
>      check_code(client, '/v4/nts/machine/1')
> 
> +    # Get a machine overview page in JSON format.
> +    check_code(client, '/v4/nts/machine/1?json=true')
> +
>      # Get the order summary page.
>      check_code(client, '/v4/nts/all_orders')

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141209/51a6b91f/attachment.html>


More information about the llvm-commits mailing list