mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-31 23:26:23 -05:00
add dao_reduce_sms_provider_priority function
retrive the sms providers from the DB, and decrease the chosen provider's priority by 10, while increasing the other by 10. add a check in to ensure we never decrease below 0 or increase above 100 - this is per provider, we don't check that the two add up to 100 or anything. If the values are outside of this range (eg: set via the UI) then they'll probably* fix themselves at some point - we've added tests to document these cases. Use with_for_update to ensure that the method can only run once at a time - other invocations of the function will be held on that line until the currently running one ends and commits the transaction. This doesn't affect anyone doing things from the UI.
This commit is contained in:
@@ -35,7 +35,7 @@ from app.dao.notifications_dao import (
|
||||
)
|
||||
from app.dao.provider_details_dao import (
|
||||
get_current_provider,
|
||||
dao_toggle_sms_provider
|
||||
dao_reduce_sms_provider_priority
|
||||
)
|
||||
from app.dao.users_dao import delete_codes_older_created_more_than_a_day_ago
|
||||
from app.models import (
|
||||
@@ -129,7 +129,7 @@ def switch_current_sms_provider_on_slow_delivery():
|
||||
)
|
||||
)
|
||||
|
||||
dao_toggle_sms_provider(current_provider.identifier)
|
||||
dao_reduce_sms_provider_priority(current_provider.identifier)
|
||||
|
||||
|
||||
@notify_celery.task(name='check-job-status')
|
||||
|
||||
Reference in New Issue
Block a user