-
Notifications
You must be signed in to change notification settings - Fork 18
Implement newsletter fallback mechanism #2730
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
base: main
Are you sure you want to change the base?
Conversation
- If the latest newsletter template_id in airtable is unable to be found in our DB, then we will fallback to the most recent template_id that we can find in our DB. Currently this looks back at the last 3 newsletter installments to find a template_id that exists in the db
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
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 implements a fallback mechanism to handle cases where the most recent newsletter template from Airtable doesn't exist in the database. When sending newsletters, the system now attempts to use the most recent template first, and if that fails, it falls back to one of the previous two templates before raising an error.
Key changes:
- Fetches up to 3 most recent newsletter template pairs from Airtable instead of just 1
- Iterates through templates with fallback logic, using the most recent available template in the database
- Adds warning logs when fallback templates are used and error logs when no valid templates are found
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| app/newsletter/rest.py | Implements fallback iteration logic through up to 3 templates with appropriate error handling and logging |
| app/clients/airtable/models.py | Updates get_latest_newsletter_templates to return 3 templates instead of 1 |
| tests/app/newsletter/test_rest.py | Adds test coverage for fallback behavior and all-templates-not-found scenario |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
- Since airtable doesn't have a native UUID column type. We cannot guarantee that newsletter_template_id_en and fr columns contain only UUIDs. We need to validate the id's when searching backwards for a valid newsletter template_id to use when sending the latest newsletter to new subscribers
This reverts commit 661c25b. As it was meant to be committed in a different branch.......
This reverts commit 87aa01d. Turns out this WAS meant for this branch. Brain is scrambled
Summary | Résumé
This PR implements a fallback mechanism for fetching newsletter templates from the DB.
How it works
template_id-> log a warning that we had to use a fallback, and which subscriber we sent that toCurrent newsletter templatesAirtable and likely requires some level of manual intervention.Test instructions | Instructions pour tester la modification
With the most recent template pair being bad data
c3b6603a-15cf-4509-a79f-524da9800da1Send me the most recent newsletterbuttonWithout bad data