Add SlackCampaignSummaryMessage schema to track posted summaries#485
Add SlackCampaignSummaryMessage schema to track posted summaries#485
Conversation
#476 Introduces a new schema and migration to store records of campaign summary messages posted to Slack. This enables tracking which campaigns have already had summaries sent. Schema fields: - slack_channel_id: Target Slack channel - raw_message: The formatted message content - sent_at: When the message was posted - campaign_id: Reference to the associated campaign The migration includes indexes on campaign_id and sent_at for efficient lookups when checking if a summary was already posted or querying by time range.
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
The "monday + week" combined filter test was failing because campaigns were created with delivery_start at 12:00 UTC, which is in the future when tests run before noon UTC. The riders_latest_campaigns view excludes campaigns where delivery_start >= NOW(), so the rider's latest_campaign was NULL. This caused the "week" filter to exclude the rider even though they had a valid Monday campaign. Change the test helper to use 00:00:00 instead of 12:00:00 for delivery_start, ensuring campaigns are always in the past relative to test execution time.
Convert the existing campaign_id index to a unique constraint to support atomic inserts with on_conflict: :nothing.
- Prevents duplicate campaign summaries
- Enables race-condition-free inserts
| end | ||
|
|
||
| defp create_campaign_for_date(date) do | ||
| datetime = DateTime.new!(date, ~T[12:00:00], "Etc/UTC") |
There was a problem hiding this comment.
The "monday + week" combined filter test was failing because campaigns were created with delivery_start at 12:00 UTC, which is in the future when tests run before noon UTC. To address the test, changed the campaign start window.
mveytsman
left a comment
There was a problem hiding this comment.
LGTM, though there's a stray change to a test
#476
Describe your changes
Introduces a new schema and migration to store records of campaign summary messages posted to Slack. This enables tracking which campaigns have already had summaries sent.
Schema fields:
The migration includes indexes on campaign_id and sent_at for efficient lookups when checking if a summary was already posted or querying by time range.
Checklist before requesting a review
about this update in the description above.