Closed jzbahrai closed 6 months ago
Began investigation, the root of the issue seems to be because we don't check if the notification(s) are scheduled before we increment in Redis in post_notifications and send_one_off_notification. Initial thoughts on solutions are below.
~1) Extend increment_todays_email_count to allow creation and incrementation of future keys.~
~2) Check, in send_one_off_notification
and post_notifications
, if the notifications are scheduled, and increment the future keys instead of current keys.~
~3) Add a method to decrement a key in the event that a user cancels scheduled notification(s)~
~1) If the notifications are scheduled, don't increment in send_one_off_notification
or post_notifications
~
~2) Delegate the increment to the task that processes the scheduled notifications, therefore incrementing the Redis keys on the day of the send.~
~Currently leaning toward the second solution, we wouldn't need to perform any decrementing if the user cancels a scheduled notification as nothing would have been incremented yet, and it doesn't require any changes to the existing Redis infrastructure that's currently in place - less of a chance to introduce more bugs while fixing a bug.~
Met with Andrew and Jumana regarding solutions for this one. We currently refresh email daily limit counts in Redis from the DB every 2 hours. The underlying query does not currently include counts from schedule jobs.
Should be wrapped up today
Code complete, tested manually, uncovered and fixed some bugs. Fixed most tests but many are failing with the changes. Will wrap it up today!
PR's are up and ready for review.
https://github.com/cds-snc/notification-utils/pull/275 https://github.com/cds-snc/notification-api/pull/2112
Our linters refuse methods that exceed a cyclomatic complexity of 15, which create_job
in app/job/rest.py
exceeded after implementing this fix. Some additional time was needed to refactor, fix tests, and regression/sanity test to ensure that functionality is intact post-refactor.
@andrewleith to review.
Code has been merged into staging, QA would be good to do on this one as it changes how we handle daily limits - we want to ensure that the daily limit is still enforced correctly.
✅ Tested - works as designed 🎉
Describe the bug
To Reproduce
I am unsure of the reasons why this is happening. Needs investigation