Reinstating the 2 task model for API submitted notifications.

This is being done for the PaaS migration to allow us to keep traffic coming in whilst we migrate the database.

uses the same tasks as the CSV uploaded notifications. Simple changes to not persist the notification, and call into a different task.
This commit is contained in:
Martyn Inglis
2017-03-23 14:41:00 +00:00
parent 5fcc80c7be
commit 1c154c4113
8 changed files with 348 additions and 106 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)