diff options
author | Tibor Frank <tifrank@cisco.com> | 2022-04-27 13:39:07 +0200 |
---|---|---|
committer | Tibor Frank <tifrank@cisco.com> | 2022-04-27 15:17:30 +0200 |
commit | 3c421a0c9690b782f299946903a928632cb36f52 (patch) | |
tree | a3154b92472e597670ee8ae059a39239b70533d2 /resources/tools/dash/app/pal/stats/layout.py | |
parent | cb61767fb2133890a786fc8f580109e9f8f3c5c5 (diff) |
feat(uti): Add constant TIME_PERIOD
It defines the time period from now back to the past from which data is
raed to dataframes.
Change-Id: Ic6feeb8e7958d69aa2e39922b48e9898e09b45dd
Signed-off-by: Tibor Frank <tifrank@cisco.com>
Diffstat (limited to 'resources/tools/dash/app/pal/stats/layout.py')
-rw-r--r-- | resources/tools/dash/app/pal/stats/layout.py | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/resources/tools/dash/app/pal/stats/layout.py b/resources/tools/dash/app/pal/stats/layout.py index 0ae83cf3a4..0c5c22e81b 100644 --- a/resources/tools/dash/app/pal/stats/layout.py +++ b/resources/tools/dash/app/pal/stats/layout.py @@ -17,6 +17,7 @@ import pandas as pd import dash_bootstrap_components as dbc +from flask import Flask from dash import dcc from dash import html from dash import callback_context, no_update @@ -33,8 +34,9 @@ class Layout: """ """ - def __init__(self, app, html_layout_file, spec_file, graph_layout_file, - data_spec_file): + def __init__(self, app: Flask, html_layout_file: str, spec_file: str, + graph_layout_file: str, data_spec_file: str, + time_period: int=None) -> None: """ """ @@ -44,12 +46,13 @@ class Layout: self._spec_file = spec_file self._graph_layout_file = graph_layout_file self._data_spec_file = data_spec_file + self._time_period = time_period # Read the data: data_stats, data_mrr, data_ndrpdr = Data( data_spec_file=self._data_spec_file, debug=True - ).read_stats() + ).read_stats(days=self._time_period) df_tst_info = pd.concat([data_mrr, data_ndrpdr], ignore_index=True) @@ -59,6 +62,11 @@ class Layout: data_stats = data_stats[~data_stats.job.str.contains("-iterative-")] data_stats = data_stats[["job", "build", "start_time", "duration"]] + data_time_period = \ + (datetime.utcnow() - data_stats["start_time"].min()).days + if self._time_period > data_time_period: + self._time_period = data_time_period + self._jobs = sorted(list(data_stats["job"].unique())) tst_info = { @@ -144,6 +152,10 @@ class Layout: def jobs(self) -> list: return self._jobs + @property + def time_period(self): + return self._time_period + def add_content(self): """ """ @@ -160,7 +172,7 @@ class Layout: ), dcc.Loading( dbc.Offcanvas( - class_name="w-50", + class_name="w-25", id="offcanvas-metadata", title="Detailed Information", placement="end", @@ -302,10 +314,13 @@ class Layout: id="dpr-period", className="d-flex justify-content-center", min_date_allowed=\ - datetime.utcnow()-timedelta(days=180), + datetime.utcnow() - timedelta( + days=self.time_period), max_date_allowed=datetime.utcnow(), initial_visible_month=datetime.utcnow(), - start_date=datetime.utcnow() - timedelta(days=180), + start_date=\ + datetime.utcnow() - timedelta( + days=self.time_period), end_date=datetime.utcnow(), display_format="D MMMM YY" ) |