2020-04-21 16:34:21 +00:00
|
|
|
from ..decorators import background
|
|
|
|
from ..models import Job
|
|
|
|
|
|
|
|
|
|
|
|
@background
|
2020-04-23 06:35:18 +00:00
|
|
|
def delete_job(job_id, *args, **kwargs):
|
|
|
|
app = kwargs['app']
|
2020-04-21 16:34:21 +00:00
|
|
|
with app.app_context():
|
|
|
|
job = Job.query.get(job_id)
|
|
|
|
if job is None:
|
2020-07-09 13:07:43 +00:00
|
|
|
raise Exception('Could not find job with id {}'.format(job_id))
|
2020-04-21 16:34:21 +00:00
|
|
|
job.delete()
|
2020-07-09 07:42:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
@background
|
|
|
|
def restart_job(job_id, *args, **kwargs):
|
|
|
|
app = kwargs['app']
|
|
|
|
with app.app_context():
|
|
|
|
job = Job.query.get(job_id)
|
|
|
|
if job is None:
|
2020-07-09 13:07:43 +00:00
|
|
|
raise Exception('Could not find job with id {}'.format(job_id))
|
2020-07-09 07:42:30 +00:00
|
|
|
job.restart()
|