remove jobs from letter api and make success/error ftp callback tasks

1. No longer create jobs when creating letters from api 🎉
2. Bulk update notifications based on the notification references after
   we send them to DVLA - either as success or as error
This commit is contained in:
Leo Hemsted
2017-09-20 11:12:37 +01:00
parent 7dd3c1df5a
commit 17ba8db97f
5 changed files with 59 additions and 27 deletions

View File

@@ -475,15 +475,19 @@ def dao_update_notifications_for_job_to_sent_to_dvla(job_id, provider):
@statsd(namespace="dao")
@transactional
def dao_update_notifications_by_reference_sent_to_dvla(notification_references, provider):
def dao_update_notifications_by_reference(references, update_dict):
now = datetime.utcnow()
updated_count = db.session.query(
Notification).filter(Notification.job_id == job_id).update(
{'status': NOTIFICATION_SENDING, "sent_by": provider, "sent_at": now})
updated_count = Notification.query().filter(
Notification.reference.in_(references)
).update(
update_dict
)
db.session.query(
NotificationHistory).filter(NotificationHistory.job_id == job_id).update(
{'status': NOTIFICATION_SENDING, "sent_by": provider, "sent_at": now, "updated_at": now})
NotificationHistory.query().filter(
NotificationHistory.reference.in_(references)
).update(
update_dict
)
return updated_count