Unverified Commit 900b4718 authored by Andreas Valder's avatar Andreas Valder
Browse files

cleaned up schedule functions

parent 40459a09
......@@ -51,11 +51,11 @@ def schedule_job(jobtype, data=None, priority=0, queue="default"):
return modify('INSERT INTO jobs (type, priority, queue, data, time_created) VALUES (?, ?, ?, ?, ?)',
jobtype, priority, queue, json.dumps(data, default=date_json_handler), datetime.now())
def cancel_job(job_id):
modify('UPDATE jobs SET state = "deleted" WHERE id = ? AND state = "ready"', job_id)
modify('UPDATE jobs SET canceled = 1 WHERE id = ?', job_id)
query('UPDATE jobs SET state = "deleted" WHERE id = ? AND state = "ready"', job_id)
query('UPDATE jobs SET canceled = 1 WHERE id = ?', job_id)
def restart_job(job_id, canceled=False):
if canceled:
modify('UPDATE jobs SET state = "ready", canceled = 0 WHERE id = ? AND state = "failed"', job_id)
query('UPDATE jobs SET state = "ready", canceled = 0 WHERE id = ? AND state = "failed"', job_id)
else:
modify('UPDATE jobs SET state = "ready" WHERE id = ? AND state = "failed" AND NOT canceled', job_id)
query('UPDATE jobs SET state = "ready" WHERE id = ? AND state = "failed" AND NOT canceled', job_id)
......@@ -19,7 +19,7 @@ def schedule_thumbnail(lectureid):
JOIN formats ON (videos.video_format = formats.id)
WHERE videos.lecture_id = ?
ORDER BY formats.prio DESC''', lectureid)
schedule_job('thumbnail', {'lectureid': str(lectureid), 'path': videos[0]['path']})
return schedule_job('thumbnail', {'lectureid': str(lectureid), 'path': videos[0]['path']})
def schedule_remux(lectureid, videoid=None):
......@@ -73,5 +73,5 @@ def schedule_transcode(source, fmt_id=None, video=None):
data['lecture_id'] = lecture['id']
data['format_id'] = fmt['id']
data['source_id'] = source['id']
schedule_job('transcode', data, queue="background")
return schedule_job('transcode', data, queue="background")
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment