1 # Copyright (c) 2022 Cisco and/or its affiliates.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
6 # http://www.apache.org/licenses/LICENSE-2.0
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
18 import dash_bootstrap_components as dbc
21 # Time period for regressions and progressions.
22 TIME_PERIOD = 21 # [days]
25 def table_news(data: pd.DataFrame, job: str) -> list:
29 job_data = data.loc[(data["job"] == job)]
30 failed = job_data["failed"].to_list()[0]
31 regressions = {"Test Name": list(), "Last Regression": list()}
32 for itm in job_data["regressions"].to_list()[0]:
33 regressions["Test Name"].append(itm[0])
34 regressions["Last Regression"].append(itm[1].strftime('%Y-%m-%d %H:%M'))
35 progressions = {"Test Name": list(), "Last Progression": list()}
36 for itm in job_data["progressions"].to_list()[0]:
37 progressions["Test Name"].append(itm[0])
38 progressions["Last Progression"].append(
39 itm[1].strftime('%Y-%m-%d %H:%M'))
42 dbc.Table.from_dataframe(pd.DataFrame.from_dict({
43 "Job": job_data["job"],
44 "Last Build": job_data["build"],
45 "Date": job_data["start"],
46 "DUT": job_data["dut_type"],
47 "DUT Version": job_data["dut_version"],
48 "Hosts": ", ".join(job_data["hosts"].to_list()[0])
49 }), bordered=True, striped=True, hover=True, size="sm", color="light"),
50 dbc.Table.from_dataframe(pd.DataFrame.from_dict({
52 f"Last Failed Tests on "
53 f"{job_data['start'].values[0]} ({len(failed)})"
55 }), bordered=True, striped=True, hover=True, size="sm", color="light"),
60 f"Regressions during the last {TIME_PERIOD} days "
61 f"({len(regressions['Test Name'])})"
64 dbc.Table.from_dataframe(
65 pd.DataFrame.from_dict(regressions),
66 bordered=True, striped=True, hover=True, size="sm", color="light"),
71 f"Progressions during the last {TIME_PERIOD} days "
72 f"({len(progressions['Test Name'])})"
75 dbc.Table.from_dataframe(
76 pd.DataFrame.from_dict(progressions),
77 bordered=True, striped=True, hover=True, size="sm", color="light")