remove jobs from letter api calls

we now no longer create a job. At the end of the post there is no
action, as we don't have any tasks to queue immediately - if it's a
real notification it'll get picked up in the evening scheduled task.

If it's a test notification, we create it with an initial status of
sending so that we can be sure it'll never get picked up - and then we
trigger the update-letter-notifications-to-sent-to-dvla task to sent
the sent-at/by.
This commit is contained in:
Leo Hemsted
2017-09-26 09:56:09 +01:00
parent daf1dc4dca
commit f3db920c71
7 changed files with 48 additions and 59 deletions

View File

@@ -3,6 +3,7 @@ from datetime import datetime
from flask import current_app
from notifications_utils.clients import redis
from notifications_utils.recipients import (
get_international_phone_info,
validate_and_format_phone_number,
@@ -11,10 +12,8 @@ from notifications_utils.recipients import (
from app import redis_store
from app.celery import provider_tasks
from notifications_utils.clients import redis
from app.config import QueueNames
from app.models import SMS_TYPE, Notification, KEY_TYPE_TEST, EMAIL_TYPE, ScheduledNotification
from app.models import SMS_TYPE, Notification, KEY_TYPE_TEST, EMAIL_TYPE, NOTIFICATION_CREATED, ScheduledNotification
from app.dao.notifications_dao import (dao_create_notification,
dao_delete_notifications_and_history_by_id,
dao_created_scheduled_notification)
@@ -52,7 +51,8 @@ def persist_notification(
client_reference=None,
notification_id=None,
simulated=False,
created_by_id=None
created_by_id=None,
status=NOTIFICATION_CREATED
):
notification_created_at = created_at or datetime.utcnow()
if not notification_id:
@@ -73,7 +73,8 @@ def persist_notification(
job_row_number=job_row_number,
client_reference=client_reference,
reference=reference,
created_by_id=created_by_id
created_by_id=created_by_id,
status=status
)
if notification_type == SMS_TYPE: