Skip to content

Add source column to distinguish live vs archived alerts (#718)#729

Merged
erikdarlingdata merged 12 commits intoerikdarlingdata:devfrom
HannahVernon:feature/alert-archive-source-718
Mar 27, 2026
Merged

Add source column to distinguish live vs archived alerts (#718)#729
erikdarlingdata merged 12 commits intoerikdarlingdata:devfrom
HannahVernon:feature/alert-archive-source-718

Conversation

@HannahVernon
Copy link
Copy Markdown
Contributor

@HannahVernon HannahVernon commented Mar 27, 2026

What does this PR do?

Issue #718 reports that alert dismissal stops working after ~20-30 alerts accumulate. One potential cause is a read/write mismatch: GetAlertHistoryAsync reads from v_config_alert_log a view that unions the live config_alert_log table with archived parquet files but DismissAlertsAsync issues UPDATE config_alert_log, which only targets the live table. Archived alerts appear in the grid but can never be dismissed because they only exist in read-only parquet files.

This PR adds a computed source column ('live' or 'archive') to the v_config_alert_log view so the UI can distinguish dismissable alerts from non-dismissable ones. No schema migration or ALTER TABLE is needed the column is purely virtual in the view definition.

Changes

File Change
Lite/Database/DuckDbInitializer.cs v_config_alert_log view now includes 'live' AS source / 'archive' AS source in all code paths (parquet present, no parquet, fallback)
Lite/Services/LocalDataService.AlertHistory.cs Both SELECT queries include source; mapped to AlertHistoryRow.Source (defaults to 'live' if NULL); new IsArchived computed property
Lite/Controls/AlertsHistoryTab.xaml DataTrigger greys out archived rows with a tooltip: This alert has been archived and cannot be dismissed.
Lite/Controls/AlertsHistoryTab.xaml.cs Dismiss Selected button disabled when only archived rows selected; dismiss handlers filter out archived alerts with clear MessageBox feedback showing live vs archived counts
Lite.Tests/Helpers/TestAlertDataHelper.cs Reusable test utility for inserting live alerts and creating archived parquet files
Lite.Tests/AlertHistorySourceTests.cs 7 xUnit tests covering live, archive, mixed scenarios

Before: All rows from the view look the same. Clicking Dismiss on an archived alert runs an UPDATE that silently affects 0 rows.

After: Archived rows are visually greyed out and cannot be selected for dismissal. If the user selects a mix of live and archived alerts, a dialog explains which ones can be dismissed.

Which component(s) does this affect?

  • Full Dashboard
  • Lite Dashboard
  • Lite Tests
  • SQL collection scripts
  • CLI Installer
  • GUI Installer
  • Documentation

How was this tested?

  • 7 new xUnit tests covering all source column scenarios:
    • LiveAlerts_HaveSourceLive live table rows get source='live'
    • ArchivedAlerts_HaveSourceArchive parquet rows get source='archive'
    • MixedAlerts_CorrectSourcePerRow mixed live+archive correctly labeled
    • DismissUpdate_OnlyAffectsLiveTable UPDATE hits live (1 row), misses archive (0 rows)
    • ViewWithNoParquet_AllRowsAreLive no parquet files = all rows are live
    • AlertHistoryRow_IsArchived_ReflectsSource model property unit test
    • MultipleParquetFiles_AllMarkedAsArchive multiple parquet files all marked archive
  • Tests use a reusable TestAlertDataHelper that creates temp DuckDB databases with live inserts and parquet archive files
  • Build passes with 0 errors, 0 new warnings

Checklist

  • I have read the contributing guide
  • My code builds with zero warnings (dotnet build -c Debug)
  • I have tested my changes against at least one SQL Server version
  • I have not introduced any hardcoded credentials or server names

HannahVernon and others added 12 commits March 10, 2026 17:08
- Parse detail_text to extract Database, Query Text, and Wait Type
  when using 'Mute This Alert' from alert history (both editions)
- Add PopulateFromDetailText() to AlertMuteContext for structured
  field extraction from the label: value format
- Add 'Default expiration for new mute rules' dropdown to Settings
  in both editions (1 hour, 24 hours, 7 days, Never; default 24h)
- MuteRuleDialog now selects the configured default expiration
  instead of always defaulting to 'Never'
- Persist setting as mute_rule_default_expiration in settings.json
  (Lite) and preferences.json (Dashboard)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The XML doc claimed Job Name extraction but the parser did not
implement it. Add the missing branch in both Dashboard and Lite
editions so the behavior matches the documentation.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Collapse newlines in Truncate/TruncateText so detail_text fields
  stay single-line in the label: value format
- Handle multi-line query values in PopulateFromDetailText by
  accumulating continuation lines until the next indented field
- Recognize variant query labels (Blocked Query, Blocking Query,
  Victim SQL) in addition to Query

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Explain that the field is a case-insensitive substring match and
suggest entering a distinctive fragment like a table or procedure name.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…data#718)

The alert history view (v_config_alert_log) unions live DuckDB rows with
archived parquet files, but UPDATE only targets the live table. Users see
archived alerts in the grid and clicking Dismiss silently does nothing.

This change adds a computed 'source' column ('live' or 'archive') to the
view so the UI can distinguish between dismissable and non-dismissable
alerts:

- DuckDbInitializer: v_config_alert_log view now includes source column
- AlertHistoryRow: new Source and IsArchived properties
- AlertsHistoryTab: archived rows greyed out with tooltip; dismiss
  handlers filter out archived alerts with clear MessageBox feedback
- Test helper and 7 xUnit tests covering live, archive, mixed scenarios

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@erikdarlingdata erikdarlingdata merged commit 5fe5994 into erikdarlingdata:dev Mar 27, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants