mirror of
https://github.com/GSA/notifications-api.git
synced 2026-09-11 18:38:14 -04:00
Updates to create job to handle scheduling
- If the job JSON contains a scheduling date then the new 'job_status" column is set to "scheduled" - the date is persisted on the JOB row in the database - Also the job WILL NOT be placed onto the queue of jobs. This is deferred to a later celery beat task.
This commit is contained in:
+11
-1
@@ -27,6 +27,8 @@ from app.schemas import (
|
||||
|
||||
from app.celery.tasks import process_job
|
||||
|
||||
from app.models import JOB_STATUS_SCHEDULED, JOB_STATUS_PENDING
|
||||
|
||||
from app.utils import pagination_links
|
||||
|
||||
job = Blueprint('job', __name__, url_prefix='/service/<uuid:service_id>/job')
|
||||
@@ -105,7 +107,15 @@ def create_job(service_id):
|
||||
raise InvalidRequest(errors, status_code=400)
|
||||
|
||||
data.update({"template_version": template.version})
|
||||
|
||||
job = job_schema.load(data).data
|
||||
|
||||
if job.scheduled_for:
|
||||
job.job_status = JOB_STATUS_SCHEDULED
|
||||
|
||||
dao_create_job(job)
|
||||
process_job.apply_async([str(job.id)], queue="process-job")
|
||||
|
||||
if job.job_status == JOB_STATUS_PENDING:
|
||||
process_job.apply_async([str(job.id)], queue="process-job")
|
||||
|
||||
return jsonify(data=job_schema.dump(job).data), 201
|
||||
|
||||
Reference in New Issue
Block a user