Skip to content

Give alerts a real snooze, an owner and a planned time - #258

Open
roncodes wants to merge 2 commits into
release/v1.6.62from
feature/alerts-snooze-assignment
Open

roncodes wants to merge 2 commits into
release/v1.6.62from
feature/alerts-snooze-assignment

Conversation

@roncodes

Copy link
Copy Markdown
Member

Summary

A triage queue (FleetOps Radar, fleetbase/fleetops#325) keeps its acknowledge / snooze / assign state on alerts, and needs to exclude snoozed alerts in the query and say who owns one. Alert::snooze() kept its wake time inside the meta JSON, so a list of open-but-not-snoozed alerts had to load every row and ask each one.

  • New columns (guarded migration): snoozed_until (indexed), snoozed_by_uuid, assigned_to_uuid, planned_at (indexed), plus a (company_uuid, status, snoozed_until) index.
  • snooze() writes the column (and who snoozed it) while keeping meta.snooze_reason; isSnoozed() reads the column and falls back to the old meta.snoozed_until for rows written before it existed.
  • New unsnooze(), assignTo(), scopeSnoozed(), scopeActive(), and assigned_to_name / is_snoozed appends.
  • acknowledge() now moves an open alert to status = acknowledged, which the status column always documented but nothing wrote.

Test plan

  • tests/Unit/Models/OperationalModelsTest.php extended for the new columns, snooze/unsnooze/assign, the legacy meta fallback and the two scopes (12 pass)
  • php artisan migrate on a database with existing alerts, then a FleetOps Radar snooze round-trip

A triage queue needs to exclude snoozed alerts in the query and to say
who owns one. `snooze()` kept its wake time inside the `meta` JSON, so a
list of open-but-not-snoozed alerts had to load every row and ask each
one. Move it to an indexed `snoozed_until` column (reading the old meta
value for rows written before it existed), record who snoozed it, add
`assigned_to_uuid` for an owner distinct from the acknowledger, and
`planned_at` for a time the owner chose to handle it.

`acknowledge()` now also moves an open alert to `acknowledged`, which the
status column always documented but nothing wrote. New `snoozed()` and
`active()` scopes, plus `unsnooze()` and `assignTo()`.
The coverage gate wanted the three one-line members the alert tests
never reached: the snoozedBy and assignedTo relations and the
assigned_to_name accessor. Assert their foreign keys and the null
fallback alongside the existing relationship contracts.
@codecov

codecov Bot commented Sep 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (546d962) to head (6c6adac).

Additional details and impacted files
@@                 Coverage Diff                 @@
##             release/v1.6.62      #258   +/-   ##
===================================================
  Coverage             100.00%   100.00%           
- Complexity              6750      6764   +14     
===================================================
  Files                    398       398           
  Lines                  22505     22548   +43     
===================================================
+ Hits                   22505     22548   +43     
Flag Coverage Δ
backend 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

1 participant