Adds another job state to account for when sending limits have been exceeded.

This commit is contained in:
Martyn Inglis
2016-03-09 13:57:53 +00:00
parent 61af70a392
commit b0074449bd
4 changed files with 90 additions and 22 deletions

View File

@@ -31,20 +31,18 @@ def process_job(job_id):
day=job.created_at.strftime(DATE_FORMAT)
)
total_sent = 0
if stats:
sending_limit = service.limit
job_size = job.notification_count
total_sent = stats.emails_requested + stats.sms_requested
if total_sent + job_size > sending_limit:
finished = datetime.utcnow()
job.status = 'finished'
job.processing_finished = finished
dao_update_job(job)
current_app.logger.info(
"Job {} size {} error. Sending limits {} exceeded".format(job_id, job.notification_count, service.limit)
)
return
if total_sent + job.notification_count > service.limit:
job.status = 'sending limits exceeded'
job.processing_finished = datetime.utcnow()
dao_update_job(job)
current_app.logger.info(
"Job {} size {} error. Sending limits {} exceeded".format(job_id, job.notification_count, service.limit)
)
return
job.status = 'in progress'
dao_update_job(job)