From fef35fbf4807452926a5da83337a8025c1de076e Mon Sep 17 00:00:00 2001 From: Erik Darling <2136037+erikdarlingdata@users.noreply.github.com> Date: Thu, 26 Mar 2026 18:37:32 -0400 Subject: [PATCH] Fix search filter not applied and slicer reset on Fetch (#147) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two regressions introduced in the time slicer PR (#114): 1. Search filter (module, query_id, etc.) was built via BuildSearchFilter() but never passed to FetchTopPlansAsync — the filter parameter was dropped when the call site switched to named parameters for startUtc/ endUtc. Add filter: back to the call. 2. Clicking Fetch reloads the slicer via LoadTimeSlicerDataAsync, which calls LoadData without preserving the current selection. LoadData defaults to last 24h when no selection is provided, discarding the user's custom range. Pass the current _slicerStartUtc/_slicerEndUtc through to LoadData's selectionStart/selectionEnd parameters. Fixes #147 Co-Authored-By: Claude Opus 4.6 (1M context) --- .../Controls/QueryStoreGridControl.axaml.cs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/PlanViewer.App/Controls/QueryStoreGridControl.axaml.cs b/src/PlanViewer.App/Controls/QueryStoreGridControl.axaml.cs index f47df61..1b1f617 100644 --- a/src/PlanViewer.App/Controls/QueryStoreGridControl.axaml.cs +++ b/src/PlanViewer.App/Controls/QueryStoreGridControl.axaml.cs @@ -151,9 +151,9 @@ private async void Fetch_Click(object? sender, RoutedEventArgs e) try { - // Load slicer data first — LoadData sets a default 24h selection and - // fires RangeChanged which triggers FetchPlansForRangeAsync. - await LoadTimeSlicerDataAsync(orderBy, ct); + // Load slicer data, preserving the current selection if one exists. + // Without this, LoadData defaults to last 24h and the user's range is lost. + await LoadTimeSlicerDataAsync(orderBy, ct, _slicerStartUtc, _slicerEndUtc); } catch (OperationCanceledException) { @@ -195,7 +195,7 @@ private async System.Threading.Tasks.Task FetchPlansForRangeAsync() try { var plans = await QueryStoreService.FetchTopPlansAsync( - _connectionString, topN, orderBy, ct: ct, + _connectionString, topN, orderBy, filter: filter, ct: ct, startUtc: _slicerStartUtc, endUtc: _slicerEndUtc); GridLoadingOverlay.IsVisible = false; @@ -363,7 +363,9 @@ private void ClearSearch_Click(object? sender, RoutedEventArgs e) SearchValueBox.Text = ""; } - private async System.Threading.Tasks.Task LoadTimeSlicerDataAsync(string metric, CancellationToken ct) + private async System.Threading.Tasks.Task LoadTimeSlicerDataAsync( + string metric, CancellationToken ct, + DateTime? preserveStart = null, DateTime? preserveEnd = null) { try { @@ -371,7 +373,7 @@ private async System.Threading.Tasks.Task LoadTimeSlicerDataAsync(string metric, _connectionString, metric, _slicerDaysBack, ct); if (ct.IsCancellationRequested) return; if (sliceData.Count > 0) - TimeRangeSlicer.LoadData(sliceData, metric); + TimeRangeSlicer.LoadData(sliceData, metric, preserveStart, preserveEnd); else StatusText.Text = "No time-slicer data available."; }