blob: 8b3b58e3bddfcec1f886f31d3281d31e54202ff0 [file] [log] [blame]
Keyar Hood0f26dba2013-07-18 17:49:32 -07001# 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
5import common
6from 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.
10from autotest_lib.frontend.tko import models as tko_models
11from django.db import models as django_models
12
13_TEST_PASS_STATUS = 'GOOD'
14
15def 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