Cleanup dailycount graph subunit2sql-graph command

The code that landed for the dailycount graph command was accidently
an early prototype version of the graph, instead of the more polished
version which was developed. This commit fixes a number of issues with
the command, first the sampling frequency was every second instead of
daily like the graph output implies. This is addressed by resampling
the time series daily. The second issues was that the default fallback
title was "Number of Tempest tests run in the Gate" which is obviously
application specific. Lastly, the date filtering both didn't work and
was using a different format than the help string perscribed. This is
fixed by using the pandas based date filtering in the analysis utils
module instead of the database api call option which uses a different
format.

Change-Id: If0fc077f2f77f6aeea914554d36cb5be8c90f323
Story: #2000311
This commit is contained in:
Matthew Treinish 2015-07-05 17:48:28 -04:00
parent 97c08f0a5c
commit 39c7ae3441
No known key found for this signature in database
GPG Key ID: FD12A0F214C9E177

View File

@ -17,6 +17,7 @@ import matplotlib.pyplot as plt
from oslo.config import cfg
import pandas as pd
from subunit2sql.analysis import utils
from subunit2sql.db import api
CONF = cfg.CONF
@ -30,14 +31,14 @@ def set_cli_opts(parser):
def generate_series():
session = api.get_session()
test_starts = api.get_test_run_series(CONF.start_date, CONF.stop_date,
session)
test_starts = api.get_test_run_series(session)
session.close()
daily_count = pd.Series(test_starts)
mean = pd.rolling_mean(daily_count, 20)
rolling_std = pd.rolling_std(daily_count, 20)
ts = pd.Series(test_starts).resample('D', how='sum')
daily_count = utils.filter_dates(ts)
mean = pd.rolling_mean(daily_count, 10)
rolling_std = pd.rolling_std(daily_count, 10)
plt.figure()
title = CONF.title or 'Number of Tempest tests run in the Gate'
title = CONF.title or 'Number of tests run'
plt.title(title)
plt.ylabel('Number of tests')
plt.plot(daily_count.index, daily_count, 'k', label='Daily Test Count')