From 7a76cf97681725f230587af9288b4fcc5e3957c1 Mon Sep 17 00:00:00 2001 From: Lukasz Sojka Date: Wed, 8 Jan 2025 18:31:58 +0100 Subject: [PATCH] improvement(graphs): add show graph button for each column in results When viewing results tables users now can view graph for selected column to see values from the past/future. closes: https://github.com/scylladb/qa-tasks/issues/1822 --- argus/backend/controller/api.py | 3 +- argus/backend/service/results_service.py | 6 +- .../TestRun/Components/ResultTable.svelte | 253 ++++++++++++++---- frontend/TestRun/ResultsGraph.svelte | 3 +- frontend/TestRun/ResultsGraphs.svelte | 71 ++--- frontend/TestRun/ResultsTab.svelte | 7 +- .../SummaryWidget/SummaryWidget.svelte | 8 +- 7 files changed, 250 insertions(+), 101 deletions(-) diff --git a/argus/backend/controller/api.py b/argus/backend/controller/api.py index 299781c2..4d2225a6 100644 --- a/argus/backend/controller/api.py +++ b/argus/backend/controller/api.py @@ -395,6 +395,7 @@ def test_results(): test_id = request.args.get("testId") start_date_str = request.args.get("startDate") end_date_str = request.args.get("endDate") + table_names = request.args.getlist("tableNames[]") if not test_id: raise Exception("No testId provided") @@ -407,7 +408,7 @@ def test_results(): exists = service.is_results_exist(test_id=UUID(test_id)) return Response(status=200 if exists else 404) - graphs, ticks, releases_filters = service.get_test_graphs(test_id=UUID(test_id), start_date=start_date, end_date=end_date) + graphs, ticks, releases_filters = service.get_test_graphs(test_id=UUID(test_id), start_date=start_date, end_date=end_date, table_names=table_names) return { "status": "ok", diff --git a/argus/backend/service/results_service.py b/argus/backend/service/results_service.py index 4ba00413..3d6a5152 100644 --- a/argus/backend/service/results_service.py +++ b/argus/backend/service/results_service.py @@ -500,9 +500,13 @@ def get_run_results(self, test_id: UUID, run_id: UUID, key_metrics: list[str] | return [{entry['table_name']: entry['table_data']} for entry in table_entries] - def get_test_graphs(self, test_id: UUID, start_date: datetime | None = None, end_date: datetime | None = None): + def get_test_graphs(self, test_id: UUID, start_date: datetime | None = None, end_date: datetime | None = None, table_names: list[str] | None = None): runs_details = self._get_runs_details(test_id) tables_meta = self._get_tables_metadata(test_id=test_id) + + if table_names: + tables_meta = [table for table in tables_meta if table.name in table_names] + graphs = [] releases_filters = set() for table in tables_meta: diff --git a/frontend/TestRun/Components/ResultTable.svelte b/frontend/TestRun/Components/ResultTable.svelte index 4b9d7160..912a875c 100644 --- a/frontend/TestRun/Components/ResultTable.svelte +++ b/frontend/TestRun/Components/ResultTable.svelte @@ -1,16 +1,32 @@
  • {table_name}
    -
    {#if showDescription} @@ -100,30 +195,49 @@
    - - - {#each result.columns as col} - - {/each} - - - - {#each result.rows as row} - + {#each result.columns as col} - {#key result.table_data[row][col.name]} - - {/key} + {/each} - {/each} + + + {#each result.rows as row} + + + {#each result.columns as col} + {#key result.table_data[row][col.name]} + + {/key} + {/each} + + {/each}
    - - {col.name} {col.unit ? `[${col.unit}]` : ''}
    {row} + + - - +
    + {col.name} + {col.unit ? `[${col.unit}]` : ""} + {#if col.unit} + + {/if} +
    +
    {row} + +
    @@ -131,6 +245,40 @@
  • +{#if showGraphModal} + +
    + {table_name} + {selectedColumnName ? `- ${selectedColumnName}` : ""} +
    +
    + + {#if graph} + {#key redraw} + + {/key} + {/if} +
    +
    +{/if} + + .column-header { + display: flex; + align-items: center; + justify-content: space-between; + gap: 0.5rem; + } + + .column-header button { + opacity: 0.6; + } + + .column-header button:hover { + opacity: 1; + } + diff --git a/frontend/TestRun/ResultsGraph.svelte b/frontend/TestRun/ResultsGraph.svelte index e35a8cb7..7cb70090 100644 --- a/frontend/TestRun/ResultsGraph.svelte +++ b/frontend/TestRun/ResultsGraph.svelte @@ -11,6 +11,7 @@ export let test_id = ""; export let width = 500; export let height = 300; + export let responsive = false; export let releasesFilters = {}; let chart; let showModal = false; @@ -118,7 +119,7 @@ const tickValues = calculateTickValues(xValues, width, ticksGapPx); graph.options.animation = false; - graph.options.responsive = false; + graph.options.responsive = responsive; graph.options.lazy = true; graph.options.plugins.tooltip = { position: "above", diff --git a/frontend/TestRun/ResultsGraphs.svelte b/frontend/TestRun/ResultsGraphs.svelte index d0db07b4..a600d5c8 100644 --- a/frontend/TestRun/ResultsGraphs.svelte +++ b/frontend/TestRun/ResultsGraphs.svelte @@ -2,6 +2,7 @@ import {createEventDispatcher, onMount} from "svelte"; import {sendMessage} from "../Stores/AlertStore"; import ResultsGraph from "./ResultsGraph.svelte"; + import GraphFilters from "./Components/GraphFilters.svelte"; import dayjs from "dayjs"; import queryString from "query-string"; @@ -91,6 +92,16 @@ fetchTestResults(test_id); }; + const handleDateChange = (event) => { + startDate = event.detail.startDate; + endDate = event.detail.endDate; + fetchTestResults(test_id); + }; + + const handleReleaseChange = () => { + filterGraphs(); + }; + const extractTableFilters = () => { let fltrs = new Map(); graphs.forEach(graph => { @@ -182,56 +193,16 @@ setDefaultDateRange(); }); -
    - Time range: -
    - - - - - - - {#if showCustomInputs} - fetchTestResults(test_id)}/> - fetchTestResults(test_id)}/> - {/if} -
    - Releases: -
    - {#each Object.keys(releasesFilters) as release} - - {/each} -
    -
    + + Filters:
    diff --git a/frontend/TestRun/ResultsTab.svelte b/frontend/TestRun/ResultsTab.svelte index f94c4544..d481ad1e 100644 --- a/frontend/TestRun/ResultsTab.svelte +++ b/frontend/TestRun/ResultsTab.svelte @@ -144,7 +144,12 @@
    diff --git a/frontend/Views/Widgets/SummaryWidget/SummaryWidget.svelte b/frontend/Views/Widgets/SummaryWidget/SummaryWidget.svelte index e2ab3ac8..8d5a365f 100644 --- a/frontend/Views/Widgets/SummaryWidget/SummaryWidget.svelte +++ b/frontend/Views/Widgets/SummaryWidget/SummaryWidget.svelte @@ -351,8 +351,12 @@ {#each results as tableEntry} {#each Object.entries(tableEntry) as [table_name, result]}
  • - +
  • {/each} {/each}