Create new task to build dvla file.

This will transform each notification in a job to a row in a file.
The file is then uploaded to S3.
The files will later be aggregated by the notifications-ftp app to send to dvla.

The method to upload the file to S3 should be pulled into notifications-utils package.
It is the same method used in notifications-admin.
This commit is contained in:
Rebecca Law
2017-03-15 15:26:58 +00:00
parent ea4214c7d5
commit 140179b4b6
6 changed files with 169 additions and 20 deletions

View File

@@ -29,12 +29,12 @@ def dao_get_notification_outcomes_for_job(service_id, job_id):
@statsd(namespace="dao")
def are_all_notifications_created_for_job(job_id):
query = db.session.query(func.count(Notification.id))\
def all_notifications_are_created_for_job(job_id):
query = db.session.query(func.count(Notification.id), Job.id)\
.join(Job)\
.filter(Job.id == job_id)\
.group_by(Job.id)\
.having(func.count(Notification.id) == Job.notification_count).first()
.having(func.count(Notification.id) == Job.notification_count).all()
if query:
return True
@@ -42,6 +42,11 @@ def are_all_notifications_created_for_job(job_id):
return False
@statsd(namespace="dao")
def dao_get_all_notifications_for_job(job_id):
return db.session.query(Notification).filter(Notification.job_id == job_id).all()
def dao_get_job_by_service_id_and_job_id(service_id, job_id):
return Job.query.filter_by(service_id=service_id, id=job_id).one()