[LNT] Add json support to machine overview page

Chris Matthews chris.matthews at apple.com
Wed Jan 21 11:44:07 PST 2015


LGTM.

> On Jan 19, 2015, at 5:06 PM, Michael Zolotukhin <mzolotukhin at apple.com> wrote:
> 
> Hi,
> 
> It turned out that fetching data from all runs for all tests isn’t a good idea - with a big enough databases it hangs the server. Thus, I’d suggest to simply report in JSON format only what’s already available in usual HTML format.
> 
> Does it look good?
> 
> 
> <lnt-json.patch>
> 
> Thanks,
> Michael
> 
> 
>> On Dec 22, 2014, at 1:57 PM, Michael Zolotukhin <mzolotukhin at apple.com <mailto:mzolotukhin at apple.com>> wrote:
>> 
>> Thanks, r224737.
>> 
>> Michael
>> 
>>> On Dec 16, 2014, at 9:22 AM, Chris Matthews <chris.matthews at apple.com <mailto:chris.matthews at apple.com>> wrote:
>>> 
>>> The bool in if's with dict.get is unneeded, get returns None on missing key, which is false. 
>>> 
>>> Otherwise, LGTM. 
>>> 
>>> On Dec 15, 2014, at 1:06 PM, Michael Zolotukhin <mzolotukhin at apple.com <mailto:mzolotukhin at apple.com>> wrote:
>>> 
>>>> Hi Chris,
>>>> 
>>>> How about this one?
>>>> 
>>>> Michael
>>>> 
>>>> Index: lnt/server/ui/views.py
>>>> ===================================================================
>>>> --- lnt/server/ui/views.py	(revision 223085)
>>>> +++ lnt/server/ui/views.py	(working copy)
>>>> @@ -172,6 +172,26 @@
>>>>              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
>>>> +        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))
>>>> +        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')
>>>> 
>>>>> On Dec 9, 2014, at 2:38 PM, Chris Matthews <chris.matthews at apple.com <mailto:chris.matthews at apple.com>> wrote:
>>>>> 
>>>>> 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 <mailto: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/20150121/7f67b423/attachment.html>


More information about the llvm-commits mailing list