OLD | NEW |
1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """Utility functions to communicate with Rietveld.""" | 5 """Utility functions to communicate with Rietveld.""" |
6 | 6 |
7 import collections | 7 import collections |
8 import json | 8 import json |
9 import logging | 9 import logging |
10 import urllib2 | 10 import urllib2 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 jobs: A list of Build objects. | 89 jobs: A list of Build objects. |
90 | 90 |
91 Returns: | 91 Returns: |
92 A list of Build objects such that only the latest job for each builder | 92 A list of Build objects such that only the latest job for each builder |
93 is kept. | 93 is kept. |
94 """ | 94 """ |
95 builder_to_highest_number = {} | 95 builder_to_highest_number = {} |
96 for j in jobs: | 96 for j in jobs: |
97 if j.build_number > builder_to_highest_number.get(j.builder_name, 0): | 97 if j.build_number > builder_to_highest_number.get(j.builder_name, 0): |
98 builder_to_highest_number[j.builder_name] = j.build_number | 98 builder_to_highest_number[j.builder_name] = j.build_number |
99 return [j for j in jobs if builder_to_highest_number[j.builder_name] == j.bu
ild_number] | 99 return [j for j in jobs if ( |
| 100 j.builder_name in builder_to_highest_number and |
| 101 builder_to_highest_number[j.builder_name] == j.build_number |
| 102 )] |
100 | 103 |
101 | 104 |
102 def get_latest_try_job_results(issue_number, web): | 105 def get_latest_try_job_results(issue_number, web): |
103 url = _latest_patchset_url(issue_number, web) | 106 url = _latest_patchset_url(issue_number, web) |
104 patchset_data = _get_json(url, web) | 107 patchset_data = _get_json(url, web) |
105 results = {} | 108 results = {} |
106 for job in patchset_data['try_job_results']: | 109 for job in patchset_data['try_job_results']: |
107 results[job['builder']] = job['result'] | 110 results[job['builder']] = job['result'] |
108 return results | 111 return results |
OLD | NEW |