feat(sla): at-risk + breach notifications via sweep worker (PMS-106) #80

Merged
vas2000-work merged 1 commit from feat/pms-106-sla-notify into main 2026-06-05 04:50:50 +02:00
Owner

Follow-up to the SLA clock engine. SlaService::with_dispatcher + SlaSweepWorker (60s) detects at-risk (now >= due - 20% window) and breach (now >= due) on open tickets, dispatches sla.at_risk/sla.breached to the assignee, deduped via a new sla_notifications ledger. Migration 027 adds the ledger + seeds in_app rules/templates (also copied to new tenants). tests/sla_notify.rs green (enqueue + dedupe) + lead-bound unit tests. clippy -D clean.

Follow-up to the SLA clock engine. SlaService::with_dispatcher + SlaSweepWorker (60s) detects at-risk (now >= due - 20% window) and breach (now >= due) on open tickets, dispatches sla.at_risk/sla.breached to the assignee, deduped via a new sla_notifications ledger. Migration 027 adds the ledger + seeds in_app rules/templates (also copied to new tenants). tests/sla_notify.rs green (enqueue + dedupe) + lead-bound unit tests. clippy -D clean.
feat(sla): at-risk + breach notifications via sweep worker (PMS-106)
All checks were successful
Check / fmt + clippy + compile + tests (pull_request) Successful in 1m2s
Build OCI container / Build and push mokosh-api image (push) Successful in 3m16s
Create release / Create release from merged PR (pull_request) Has been skipped
e1244a0901
Follow-up to the SLA clock engine: actually notify on at-risk/breach. SlaService gains a with_dispatcher constructor holding an optional NotificationsService (mirrors AuthService). A new SlaSweepWorker (scheduler Job, 60s) scans open tickets with first_response_due/resolution_due set: a target is breached when now >= due and at-risk when now >= due - lead (lead = 20% of the created->due window, clamped 5min..24h). For each newly-crossed (ticket, kind) it dispatches sla.at_risk / sla.breached with the assignee as recipient and records it in a new sla_notifications ledger (UNIQUE(ticket_id, kind)) so each milestone fires once.

Migration 027 adds the ledger and seeds default-tenant notification templates + active rules for both events (channel in_app); create_tenant copies them to new tenants. tests/sla_notify.rs asserts a past-due ticket enqueues one notification + ledger row and a second tick is a no-op (dedupe); plus unit tests for the lead bounds.

#PMS-106

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
vas2000-work deleted branch feat/pms-106-sla-notify 2026-06-05 04:50:50 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
psa-systems/mokosh-server!80
No description provided.