-
Notifications
You must be signed in to change notification settings - Fork 18
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
Fix daily limit counting when scheduling jobs #2112
Conversation
- When scheduling a job, the daily limits in Redis will only be incremented if the job was scheduled for the current day - When refreshing daily count keys from the DB the underlying query will now include counts from jobs scheduled for the current day - Experimenting with a new decorator for feature flags - Fixed an issue with the dev container where the poetry installation will sometimes not be detected by adding the installation dir to the $PATH
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.
Looks good but I'm not sure why the tests are failing. The new utils is tagged so I thought it would pass.
Yea, I've had this happen once before, where it acts like the tag didn't stick. I had to bump the version again but luckily it looks like there's another bump on the way. I'll bump the version in this PR once that is merged. Hopefully it resolves itself. |
increment_email_daily_count_send_warnings_if_needed(service, len(list(recipient_csv.get_rows()))) | ||
if scheduled_for is None or not scheduled_for.date() > datetime.today().date(): | ||
increment_email_daily_count_send_warnings_if_needed( | ||
authenticated_service, len(list(recipient_csv.get_rows())) # noqa: F821 |
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.
This is still failing local smoke tests. authenticated_service
doesnt seem to have the id
property this method expects it to have.
Summary | Résumé
Jobs scheduled for > today were being counted toward the current day's daily limit, causing services to hit their daily sending limit before they should have.
Depends on this Utils PR
Changelog:
$PATH
when running thepostCreate
hook on dev container creation. This should resolve an occasional issue wherepoetry
could not be found once the container finishes building.create_job
inapp/job/rest.py
to reduce it's cyclomatic complexity < 15.Testing
Redis keys to observe throughout the tests
email-{service_id}-count
{service_id}-{current_date}-count
Notes:
Jobs scheduled for tomorrow or later do not increment Redis counts
Jobs scheduled within the current day increment the Redis counts
Canceling a job scheduled for the current day decrements the Redis counts
Jobs scheduled within the current day, but were canceled, are not counted when the
email-{service_id}-count
key is refreshed from the DB