Skip to content

Clean up event alerts and ensure reliable dedupe#259

Merged
sfreeman422 merged 5 commits into
masterfrom
feature/event-alerting
Jun 9, 2026
Merged

Clean up event alerts and ensure reliable dedupe#259
sfreeman422 merged 5 commits into
masterfrom
feature/event-alerting

Conversation

@sfreeman422

@sfreeman422 sfreeman422 commented Jun 5, 2026

Copy link
Copy Markdown
Collaborator

Refines EventAlertJob alert formatting and fixes dedupe reliability for split alert sections.

The job now still separates occurrences into:

  • Happening today
  • Upcoming in the next 24 hours

But when both sections exist, it sends them as a single combined Slack message instead of two separate posts. This prevents partial-send scenarios from causing duplicate re-alerts on retry, since dedupe keys are written after one successful send.

Updated unit tests in packages/backend/src/jobs/event-alert.job.spec.ts to validate the single-message behavior and section content.

Copilot AI review requested due to automatic review settings June 5, 2026 18:27

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors EventAlertJob’s Slack alert formatting to produce cleaner, more structured event notifications by splitting occurrences into “Happening today” vs “Upcoming in the next 24 hours” buckets.

Changes:

  • Added UTC-day helpers and bucketing logic to separate “today” occurrences from later occurrences within the same 24-hour lookahead.
  • Extracted alert formatting into reusable helpers (formatOccurrenceLine, formatAlertSection, formatAlertMessage).
  • Updated/added unit tests to assert the new message headers and two-message behavior when both buckets exist.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
packages/backend/src/jobs/event-alert.job.ts Adds UTC-day bucketing and refactors Slack message formatting; may send up to two messages per run/team.
packages/backend/src/jobs/event-alert.job.spec.ts Updates expectations for new “Happening today” header and adds coverage for splitting today vs later occurrences.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/backend/src/jobs/event-alert.job.ts Outdated
Comment on lines +162 to +169
if (upcomingMessage) {
await this.webService.sendMessage(ALERT_CHANNEL, `${upcomingMessage}${overflowLine}`);
}

// Always send today alerts last when both buckets have events.
if (todayMessage) {
await this.webService.sendMessage(ALERT_CHANNEL, `${todayMessage}${overflowLine}`);
}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot make a choice and go with it

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implemented option (a): alerts are now sent as a single combined Slack message (upcoming + today sections), then dedupe keys are written after that one successful send. Addressed in commits 4141cd8 and 33b56bc.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI changed the title Updated alerts to be cleaner Clean up event alerts and ensure reliable dedupe Jun 9, 2026
@sfreeman422 sfreeman422 requested a review from Copilot June 9, 2026 02:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment thread packages/backend/src/jobs/event-alert.job.ts Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@sfreeman422 sfreeman422 merged commit c0f16be into master Jun 9, 2026
10 checks passed
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.

3 participants