Skip to content

Signal-arm the deadline warning and delete the sweep - #1097

Open
johnpooch wants to merge 1 commit into
mainfrom
claude/diplicity-react-1073-fly5n0
Open

Signal-arm the deadline warning and delete the sweep#1097
johnpooch wants to merge 1 commit into
mainfrom
claude/diplicity-react-1073-fly5n0

Conversation

@johnpooch

Copy link
Copy Markdown
Owner

What this PR does

Closes #1073. Replaces the every-minute phase.send_deadline_warnings cron sweep with a per-phase job armed at scheduled_resolution - threshold, re-armed when the deadline or status changes and evaluated at fire time — mirroring the existing phase-resolution arming.

Because recipients are evaluated when the job fires (not when it's armed), confirm / unconfirm / extension all "just work" with no per-player cancellation, which lets the old per-player deadline_warning_sent_for dedup marker go away entirely.

Changes:

  • Add Phase.warning_job_id (migration 0017) and drop the now-unused PhaseState.deadline_warning_sent_for field.
  • Move the warning-threshold table out of the sweep into phase.utils.deadline_warning_offset, which the arm computation owns.
  • Add arm_deadline_warning alongside arm_deadline_resolution, both dispatched from a single arm_deadline_jobs post_save receiver that cancels and re-arms each job on change.
  • Add the phase.send_deadline_warning(phase_id) task + manager method, which evaluates recipients at fire time (has_possible_orders, not confirmed, active) and emits deadline_warning.
  • Delete the periodic sweep task and the send_deadline_warnings manager method. The resolution canary sweep (sweep_due_phases) is untouched.

Checklist

  • This PR does one thing — no unrelated fixes, refactors, or drive-by cleanups bundled in
  • For PRs of any significant complexity: I ran /review-pr against this PR in Claude Code and addressed (or responded to) its findings
  • Tests cover the change
  • Screenshots embedded in the PR description for any visual changes (see CLAUDE.md) — N/A, backend-only

🤖 Generated with Claude Code


Generated by Claude Code

Replace the `phase.send_deadline_warnings` periodic cron sweep with a
per-phase job armed at `scheduled_resolution - threshold`, mirroring the
existing phase-resolution arming.

- Add `Phase.warning_job_id` (migration) and drop the now-unused
  `PhaseState.deadline_warning_sent_for` marker; dedup is inherent to a
  single armed job re-armed on change.
- Move the warning-threshold table into `phase.utils.deadline_warning_offset`
  so the arm computation owns it.
- Add `arm_deadline_warning` alongside `arm_deadline_resolution`, dispatched
  from a single `arm_deadline_jobs` post_save receiver that cancels and
  re-arms both jobs when the deadline or status changes.
- Add the `phase.send_deadline_warning(phase_id)` task and manager method
  that evaluate recipients at fire time (has_possible_orders, not confirmed,
  active), so confirm / unconfirm / extension need no per-player cancellation.
- Delete the periodic sweep task and the `send_deadline_warnings` manager
  method; migrate tests to the per-phase method and add warning-arming tests.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018trT4XjJMoto7uxYkafSBp
@github-actions

Copy link
Copy Markdown
Contributor

Warning

WIP limit exceeded. There are now 9 open pull requests — the project target is 5 or fewer.

Please close or merge an existing PR before continuing with this one.

@netlify

netlify Bot commented Jul 23, 2026

Copy link
Copy Markdown

Deploy Preview for diplicity-variant-creator canceled.

Name Link
🔨 Latest commit 05e6ef4
🔍 Latest deploy log https://app.netlify.com/projects/diplicity-variant-creator/deploys/6a6240d47108d900077c3767

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.

Notifications PR 5: signal-arm the deadline warning and delete the sweep

2 participants