X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=resources%2Ftools%2Fdash%2Fapp%2Fpal%2Fstats%2Fgraphs.py;h=42f23da5aa1054e04681f37476790b327573e462;hb=refs%2Fchanges%2F94%2F36794%2F4;hp=db6937402ab535dec428a1c422b93eee5f374c9d;hpb=88853d7d4e4461198213b9db021fe4e4985c9533;p=csit.git
diff --git a/resources/tools/dash/app/pal/stats/graphs.py b/resources/tools/dash/app/pal/stats/graphs.py
index db6937402a..42f23da5aa 100644
--- a/resources/tools/dash/app/pal/stats/graphs.py
+++ b/resources/tools/dash/app/pal/stats/graphs.py
@@ -21,7 +21,19 @@ from datetime import datetime, timedelta
def select_data(data: pd.DataFrame, itm:str, start: datetime,
end: datetime) -> pd.DataFrame:
- """
+ """Select the data for graphs from the provided data frame.
+
+ :param data: Data frame with data for graphs.
+ :param itm: Item (in this case job name) which data will be selected from
+ the input data frame.
+ :param start: The date (and time) when the selected data starts.
+ :param end: The date (and time) when the selected data ends.
+ :type data: pandas.DataFrame
+ :type itm: str
+ :type start: datetime.datetime
+ :type end: datetime.datetime
+ :returns: A data frame with selected data.
+ :rtype: pandas.DataFrame
"""
df = data.loc[
@@ -36,7 +48,24 @@ def select_data(data: pd.DataFrame, itm:str, start: datetime,
def graph_statistics(df: pd.DataFrame, job:str, layout: dict,
start: datetime=datetime.utcnow()-timedelta(days=180),
end: datetime=datetime.utcnow()) -> tuple:
- """
+ """Generate graphs:
+ 1. Passed / failed tests,
+ 2. Job durations
+ with additional information shown in hover.
+
+ :param df: Data frame with input data.
+ :param job: The name of job which data will be presented in the graphs.
+ :param layout: Layout of plot.ly graph.
+ :param start: The date (and time) when the selected data starts.
+ :param end: The date (and time) when the selected data ends.
+ :type df: pandas.DataFrame
+ :type job: str
+ :type layout: dict
+ :type start: datetime.datetime
+ :type end: datetime.datetime
+ :returns: Tuple with two generated graphs (pased/failed tests and job
+ duration).
+ :rtype: tuple(plotly.graph_objects.Figure, plotly.graph_objects.Figure)
"""
data = select_data(df, job, start, end)
@@ -47,7 +76,7 @@ def graph_statistics(df: pd.DataFrame, job:str, layout: dict,
for _, row in data.iterrows():
d_type = "trex" if row["dut_type"] == "none" else row["dut_type"]
hover_itm = (
- f"date: {row['start_time'].strftime('%d-%m-%Y %H:%M:%S')}
"
+ f"date: {row['start_time'].strftime('%Y-%m-%d %H:%M:%S')}
"
f"duration: "
f"{(int(row['duration']) // 3600):02d}:"
f"{((int(row['duration']) % 3600) // 60):02d}
"