Add db api method to get status time series
This commit adds a new db api method to get a time series of test run statuses. This is useful for graphing an individual tests success or failure count over time. Change-Id: Idae782404bcc570f6ffd2f3bb805c49df9283ac6
This commit is contained in:
parent
7585906bda
commit
e244ff3d1f
@ -586,6 +586,30 @@ def get_test_run_time_series(test_id, session=None):
|
|||||||
return time_series
|
return time_series
|
||||||
|
|
||||||
|
|
||||||
|
def get_test_status_time_series(test_id, session=None):
|
||||||
|
"""Returns a time series dict of test_run statuses of a single test
|
||||||
|
|
||||||
|
:param str test_id: The test's uuid (the id column in the test table) which
|
||||||
|
will be used to get all the test run times for.
|
||||||
|
:param session: optional session object if one isn't provided a new session
|
||||||
|
|
||||||
|
:return dict: A dictionary with the start times as the keys and the values
|
||||||
|
being the status of that test run.
|
||||||
|
"""
|
||||||
|
session = session or get_session()
|
||||||
|
query = db_utils.model_query(models.TestRun, session=session).filter_by(
|
||||||
|
test_id=test_id).values(
|
||||||
|
models.TestRun.start_time, models.TestRun.start_time_microsecond,
|
||||||
|
models.TestRun.status)
|
||||||
|
status_series = {}
|
||||||
|
for test_run in query:
|
||||||
|
start_time = test_run[0]
|
||||||
|
start_time = start_time.replace(microsecond=test_run[1])
|
||||||
|
status = test_run[2]
|
||||||
|
status_series[start_time] = status
|
||||||
|
return status_series
|
||||||
|
|
||||||
|
|
||||||
def get_recent_successful_runs(num_runs=10, session=None):
|
def get_recent_successful_runs(num_runs=10, session=None):
|
||||||
"""Return a list of run uuid strings for the most recent successful runs
|
"""Return a list of run uuid strings for the most recent successful runs
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user