Skip to content

Incident dual status creates confusing state between persisted and computed status #336

@jbrooksuk

Description

@jbrooksuk

Priority: P2 (High - Fix Soon)

Problem

The Incident model has both a persisted status column AND a computed latestStatus attribute that looks at the latest Update. This creates inconsistencies across the codebase:

  • Filament table (IncidentResource.php:127) displays latest_status
  • API resource (Incident.php:27) returns latestStatus
  • Filament filter (:165) filters on the raw status column
  • scopeUnresolved() (:170) queries the raw status column
  • Navigation badge (:246-250) tries to reconcile both by querying unresolved() (raw status) then re-filtering by latest_status

This means an incident marked "investigating" in the DB but with a "fixed" update will still appear in scopeUnresolved() scope queries but then get filtered out in the badge — causing an N+1-like post-filter on every page load.

Suggested Fix

Consider a status computed column or event-driven sync so that the persisted status always reflects the latest update. Alternatively, make scopeUnresolved() join the updates table (as Status.php already does).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions