diff options
author | Tibor Frank <tifrank@cisco.com> | 2024-03-20 05:43:03 +0000 |
---|---|---|
committer | Tibor Frank <tifrank@cisco.com> | 2024-03-22 08:38:36 +0000 |
commit | 230044632667a3eb7794218a6ba3e2fa2c9b71b4 (patch) | |
tree | 7e132acf27b291c4898b38c4e6490e1cc682c973 /csit.infra.dash/app/cdash/utils | |
parent | 18cf48d954d1e814430211e69b04718ae9c7d03c (diff) |
C-Dash: Add detailed views to comparison tables
Change-Id: I0936f736497299f8b9fc1254012b2a0b20c41bfb
Signed-off-by: Tibor Frank <tifrank@cisco.com>
Diffstat (limited to 'csit.infra.dash/app/cdash/utils')
-rw-r--r-- | csit.infra.dash/app/cdash/utils/utils.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/csit.infra.dash/app/cdash/utils/utils.py b/csit.infra.dash/app/cdash/utils/utils.py index 3d2866fbe0..692e45efb2 100644 --- a/csit.infra.dash/app/cdash/utils/utils.py +++ b/csit.infra.dash/app/cdash/utils/utils.py @@ -631,6 +631,39 @@ def filter_table_data( return df.to_dict("records") +def sort_table_data( + store_table_data: list, + sort_by: list + ) -> list: + """Sort table data using user specified order. + + :param store_table_data: Table data represented as a list of records. + :param sort_by: User specified sorting order (multicolumn). + :type store_table_data: list + :type sort_by: list + :returns: A new table created by sorting the table data represented as + a list of records. + :rtype: list + """ + + # Checks: + if not any((sort_by, store_table_data, )): + return store_table_data + + df = pd.DataFrame.from_records(store_table_data) + if len(sort_by): + dff = df.sort_values( + [col["column_id"] for col in sort_by], + ascending=[col["direction"] == "asc" for col in sort_by], + inplace=False + ) + else: + # No sort is applied + dff = df + + return dff.to_dict("records") + + def show_trending_graph_data( trigger: Trigger, data: dict, |