OLD | NEW |
1 import os, pickle, datetime, itertools, operator | 1 import os, pickle, datetime, itertools, operator |
2 from django.db import models as dbmodels | 2 from django.db import models as dbmodels |
3 from autotest_lib.frontend.afe import rpc_utils, model_logic | 3 from autotest_lib.frontend.afe import rpc_utils, model_logic |
4 from autotest_lib.frontend.afe import models as afe_models, readonly_connection | 4 from autotest_lib.frontend.afe import models as afe_models, readonly_connection |
5 from autotest_lib.frontend.tko import models, tko_rpc_utils, graphing_utils | 5 from autotest_lib.frontend.tko import models, tko_rpc_utils, graphing_utils |
6 from autotest_lib.frontend.tko import preconfigs | 6 from autotest_lib.frontend.tko import preconfigs |
7 | 7 |
8 # table/spreadsheet view support | 8 # table/spreadsheet view support |
9 | 9 |
10 def get_test_views(**filter_data): | 10 def get_test_views(**filter_data): |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 | 166 |
167 all_iterations = iteration_attr.keys() + iteration_perf.keys() | 167 all_iterations = iteration_attr.keys() + iteration_perf.keys() |
168 max_iterations = max(all_iterations + [0]) | 168 max_iterations = max(all_iterations + [0]) |
169 | 169 |
170 # merge the iterations into a single list of attr & perf dicts | 170 # merge the iterations into a single list of attr & perf dicts |
171 return [{'attr': iteration_attr.get(index, {}), | 171 return [{'attr': iteration_attr.get(index, {}), |
172 'perf': iteration_perf.get(index, {})} | 172 'perf': iteration_perf.get(index, {})} |
173 for index in xrange(1, max_iterations + 1)] | 173 for index in xrange(1, max_iterations + 1)] |
174 | 174 |
175 | 175 |
| 176 def _job_keyvals_to_dict(keyvals): |
| 177 return dict((keyval.key, keyval.value) for keyval in keyvals) |
| 178 |
| 179 |
176 def get_detailed_test_views(**filter_data): | 180 def get_detailed_test_views(**filter_data): |
177 test_views = models.TestView.list_objects(filter_data) | 181 test_views = models.TestView.list_objects(filter_data) |
| 182 |
178 tests_by_id = models.Test.objects.in_bulk([test_view['test_idx'] | 183 tests_by_id = models.Test.objects.in_bulk([test_view['test_idx'] |
179 for test_view in test_views]) | 184 for test_view in test_views]) |
180 tests = tests_by_id.values() | 185 tests = tests_by_id.values() |
181 models.Test.objects.populate_relationships(tests, models.TestAttribute, | 186 models.Test.objects.populate_relationships(tests, models.TestAttribute, |
182 'attributes') | 187 'attributes') |
183 models.Test.objects.populate_relationships(tests, models.IterationAttribute, | 188 models.Test.objects.populate_relationships(tests, models.IterationAttribute, |
184 'iteration_attributes') | 189 'iteration_attributes') |
185 models.Test.objects.populate_relationships(tests, models.IterationResult, | 190 models.Test.objects.populate_relationships(tests, models.IterationResult, |
186 'iteration_results') | 191 'iteration_results') |
187 models.Test.objects.populate_relationships(tests, models.TestLabel, | 192 models.Test.objects.populate_relationships(tests, models.TestLabel, |
188 'labels') | 193 'labels') |
| 194 |
| 195 jobs_by_id = models.Job.objects.in_bulk([test_view['job_idx'] |
| 196 for test_view in test_views]) |
| 197 jobs = jobs_by_id.values() |
| 198 models.Job.objects.populate_relationships(jobs, models.JobKeyval, |
| 199 'keyvals') |
| 200 |
189 for test_view in test_views: | 201 for test_view in test_views: |
190 test = tests_by_id[test_view['test_idx']] | 202 test = tests_by_id[test_view['test_idx']] |
191 test_view['attributes'] = _attributes_to_dict(test.attributes) | 203 test_view['attributes'] = _attributes_to_dict(test.attributes) |
192 test_view['iterations'] = _format_iteration_keyvals(test) | 204 test_view['iterations'] = _format_iteration_keyvals(test) |
193 test_view['labels'] = [label.name for label in test.labels] | 205 test_view['labels'] = [label.name for label in test.labels] |
| 206 |
| 207 job = jobs_by_id[test_view['job_idx']] |
| 208 test_view['job_keyvals'] = _job_keyvals_to_dict(job.keyvals) |
| 209 |
194 return rpc_utils.prepare_for_serialization(test_views) | 210 return rpc_utils.prepare_for_serialization(test_views) |
195 | 211 |
196 # graphing view support | 212 # graphing view support |
197 | 213 |
198 def get_hosts_and_tests(): | 214 def get_hosts_and_tests(): |
199 """\ | 215 """\ |
200 Gets every host that has had a benchmark run on it. Additionally, also | 216 Gets every host that has had a benchmark run on it. Additionally, also |
201 gets a dictionary mapping the host names to the benchmarks. | 217 gets a dictionary mapping the host names to the benchmarks. |
202 """ | 218 """ |
203 | 219 |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 result['test_labels'] = get_test_labels(sort_by=['name']) | 435 result['test_labels'] = get_test_labels(sort_by=['name']) |
420 result['current_user'] = rpc_utils.prepare_for_serialization( | 436 result['current_user'] = rpc_utils.prepare_for_serialization( |
421 afe_models.User.current_user().get_object_dict()) | 437 afe_models.User.current_user().get_object_dict()) |
422 result['benchmark_key'] = benchmark_key | 438 result['benchmark_key'] = benchmark_key |
423 result['tko_perf_view'] = tko_perf_view | 439 result['tko_perf_view'] = tko_perf_view |
424 result['tko_test_view'] = model_fields | 440 result['tko_test_view'] = model_fields |
425 result['preconfigs'] = preconfigs.manager.all_preconfigs() | 441 result['preconfigs'] = preconfigs.manager.all_preconfigs() |
426 result['motd'] = rpc_utils.get_motd() | 442 result['motd'] = rpc_utils.get_motd() |
427 | 443 |
428 return result | 444 return result |
OLD | NEW |