Merge pull request #866 from alphagov/no-downtime-hosting-migration

Reinstating the 2 task model for API submitted notifications.
This commit is contained in:
minglis
2017-03-27 13:54:43 +01:00
committed by GitHub
9 changed files with 350 additions and 108 deletions

View File

@@ -123,6 +123,39 @@ def process_row(row_number, recipient, personalisation, template, job, service):
)
def send_notification_to_persist_queue(
notification_id, service, template_type, encrypted, priority=False, research_mode=False
):
queues = {
SMS_TYPE: 'db-sms',
EMAIL_TYPE: 'db-email'
}
send_fns = {
SMS_TYPE: send_sms,
EMAIL_TYPE: send_email
}
send_fn = send_fns[template_type]
if research_mode:
queue_name = "research-mode"
elif priority:
queue_name = "notify"
else:
queue_name = queues[template_type]
send_fn.apply_async(
(
str(service.id),
notification_id,
encrypted,
datetime.utcnow().strftime(DATETIME_FORMAT)
),
queue=queue_name
)
def __sending_limits_for_job_exceeded(service, job, job_id):
total_sent = fetch_todays_total_message_count(service.id)