Keyar Hood | 0f26dba | 2013-07-18 17:49:32 -0700 | [diff] [blame^] | 1 | # Copyright (c) 2013 The Chromium OS Authors. All rights reserved. |
| 2 | # Use of this source code is governed by a BSD-style license that can be |
| 3 | # found in the LICENSE file. |
| 4 | |
| 5 | import common |
| 6 | from autotest_lib.frontend import setup_django_readonly_environment |
| 7 | |
| 8 | # Django and the models are only setup after |
| 9 | # the setup_django_readonly_environment module is imported. |
| 10 | from autotest_lib.frontend.tko import models as tko_models |
| 11 | from django.db import models as django_models |
| 12 | |
| 13 | _TEST_PASS_STATUS = 'GOOD' |
| 14 | |
| 15 | def get_last_pass_times(): |
| 16 | """ |
| 17 | Get all the tests that have passed and the time they last passed. |
| 18 | |
| 19 | @return the dict of test_name:last_finish_time pairs for tests that have |
| 20 | passed. |
| 21 | |
| 22 | """ |
| 23 | results = tko_models.Test.objects.values('test').filter( |
| 24 | status__word=_TEST_PASS_STATUS).annotate( |
| 25 | last_pass=django_models.Max('started_time')) |
| 26 | return {result['test']: result['last_pass'] for result in results} |
| 27 | |