-
Notifications
You must be signed in to change notification settings - Fork 0
feat(rfp): 24h pending-RFP SLA breach email to leadership #864
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f364e18
feat(rfp): 24h pending-RFP SLA breach email to leadership
artificialadnaan f12d21c
fix(rfp): harden the SLA scan to mirror the Pending RFP queue exactly…
artificialadnaan d52aa20
fix(rfp): SLA scan single-flight + stage re-check + idempotent payloa…
artificialadnaan 8b6a76b
fix(rfp): destroy the advisory-lock connection when unlock fails
artificialadnaan 7c939e0
perf(rfp): resolve Opportunity stage ids once per SLA scan, not per o…
artificialadnaan 50049eb
fix(rfp): persist a display snapshot before send so retries stay idem…
artificialadnaan be274f2
docs(rfp): rewrite the 0174 header to the claim-then-send protocol
artificialadnaan 2ad9904
fix(rfp-sla): freeze recipient set in the claim snapshot for idempote…
artificialadnaan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| -- 0174_rfp_pending_sla_email_receipts.sql | ||
| -- | ||
| -- Exactly-once ledger for the Pending RFP 24h SLA breach email (worker/src/jobs/rfp-pending-sla.ts). | ||
| -- | ||
| -- WHY: an RFP that stays in the "Pending RFP" bucket (stage=opportunity, not bid-board-owned, | ||
| -- rfp_approval_status in pending_outbox/pending) longer than 24h should alert leadership. Unlike the | ||
| -- decline email (0148), an SLA breach is TIME-based, not a status transition, so no DB trigger fires it — | ||
| -- the worker runs an hourly cron scan instead. Scanning hourly means the same breach is seen many times, so | ||
| -- this ledger is the exactly-once guard: the scan INSERTs a claim row ON CONFLICT DO NOTHING BEFORE sending, | ||
| -- and a send failure DELETEs the claim so the next scan retries. | ||
| -- | ||
| -- CYCLE IDENTITY: keyed (tenant_schema, deal_id, rfp_approval_requested_at). rfp_approval_requested_at is | ||
| -- the instant the RFP entered pending; a re-triggered RFP gets a NEW requested_at -> a fresh cycle -> a new | ||
| -- alert (correct). This is a PUBLIC table (one row per office+deal+cycle), same shape as 0148's | ||
| -- rfp_rejection_email_receipts; no per-tenant copy is needed. | ||
| -- | ||
| -- This ships with the WORKER (the hourly job) and is gated behind RFP_PENDING_SLA_ENABLED so it merges inert. | ||
|
|
||
| CREATE TABLE IF NOT EXISTS public.rfp_pending_sla_email_receipts ( | ||
| tenant_schema text NOT NULL, | ||
| deal_id uuid NOT NULL, | ||
| rfp_approval_requested_at timestamptz NOT NULL, | ||
| deal_number text, | ||
| recipient_emails text, | ||
| resend_message_id text, | ||
| sent_at timestamptz NOT NULL DEFAULT NOW(), | ||
| created_at timestamptz NOT NULL DEFAULT NOW(), | ||
| updated_at timestamptz NOT NULL DEFAULT NOW(), | ||
| PRIMARY KEY (tenant_schema, deal_id, rfp_approval_requested_at) | ||
| ); | ||
|
|
||
| CREATE INDEX IF NOT EXISTS rfp_pending_sla_email_receipts_deal_idx | ||
| ON public.rfp_pending_sla_email_receipts (tenant_schema, deal_id); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.