Skip to content
Snippets Groups Projects
Unverified Commit 900b4718 authored by Andreas Valder's avatar Andreas Valder
Browse files

cleaned up schedule functions

parent 40459a09
No related branches found
No related tags found
Loading
...@@ -51,11 +51,11 @@ def schedule_job(jobtype, data=None, priority=0, queue="default"): ...@@ -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 (?, ?, ?, ?, ?)', return modify('INSERT INTO jobs (type, priority, queue, data, time_created) VALUES (?, ?, ?, ?, ?)',
jobtype, priority, queue, json.dumps(data, default=date_json_handler), datetime.now()) jobtype, priority, queue, json.dumps(data, default=date_json_handler), datetime.now())
def cancel_job(job_id): def cancel_job(job_id):
modify('UPDATE jobs SET state = "deleted" WHERE id = ? AND state = "ready"', job_id) query('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 canceled = 1 WHERE id = ?', job_id)
def restart_job(job_id, canceled=False): def restart_job(job_id, canceled=False):
if canceled: 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: 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): ...@@ -19,7 +19,7 @@ def schedule_thumbnail(lectureid):
JOIN formats ON (videos.video_format = formats.id) JOIN formats ON (videos.video_format = formats.id)
WHERE videos.lecture_id = ? WHERE videos.lecture_id = ?
ORDER BY formats.prio DESC''', lectureid) 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): def schedule_remux(lectureid, videoid=None):
...@@ -73,5 +73,5 @@ def schedule_transcode(source, fmt_id=None, video=None): ...@@ -73,5 +73,5 @@ def schedule_transcode(source, fmt_id=None, video=None):
data['lecture_id'] = lecture['id'] data['lecture_id'] = lecture['id']
data['format_id'] = fmt['id'] data['format_id'] = fmt['id']
data['source_id'] = source['id'] data['source_id'] = source['id']
schedule_job('transcode', data, queue="background") return schedule_job('transcode', data, queue="background")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment