mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-04 02:11:11 -05:00
Add an endpoint to cancel a job
If you schedule a job you might change your mind or circumstances might change. So you need to be able to cancel it. This commit adds a `POST` endpoint for individual jobs which sets their status to `cancelled`. This also means adding a new status of `cancelled`, so there’s a migration…
This commit is contained in:
@@ -44,6 +44,13 @@ def dao_get_scheduled_jobs():
|
||||
.all()
|
||||
|
||||
|
||||
def dao_get_future_scheduled_job_by_id_and_service_id(job_id, service_id):
|
||||
return Job.query \
|
||||
.filter_by(service_id=service_id, id=job_id) \
|
||||
.filter(Job.job_status == 'scheduled', Job.scheduled_for > datetime.utcnow()) \
|
||||
.one()
|
||||
|
||||
|
||||
def dao_create_job(job):
|
||||
db.session.add(job)
|
||||
db.session.commit()
|
||||
|
||||
Reference in New Issue
Block a user