Skip to content
Snippets Groups Projects
Commit b448ee30 authored by Simon Künzel's avatar Simon Künzel
Browse files

Use true/false for booleans in sql

parent b34ac20d
No related branches found
No related tags found
No related merge requests found
......@@ -15,7 +15,7 @@ def import_xmp_chapters(jobid, jobtype, data, state, status): #pylint: disable=u
if int(chapter['time']) in times:
continue
modify(
'INSERT INTO chapters (lecture_id, time, text, visible, time_created, time_updated) VALUES (?, ?, ?, 0, ?, ?)',
'INSERT INTO chapters (lecture_id, time, text, visible, time_created, time_updated) VALUES (?, ?, ?, false, ?, ?)',
data['lecture_id'], int(chapter['time']), chapter['text'],
datetime.now(), datetime.now()
)
......
......@@ -182,7 +182,7 @@ def edit(prefix='', ignore=None):
modify('INSERT INTO changelog \
("table",id_value, id_key, field, value_new, value_old, "when", who, executed) \
VALUES (?,?,?,?,?, \
(SELECT "%s" FROM %s WHERE %s = ?),?,?,1)'%(
(SELECT "%s" FROM %s WHERE %s = ?),?,?,true)'%(
path['column'],
path['tableinfo']['table'],
path['tableinfo']['idcolumn']
......
......@@ -54,10 +54,10 @@ def schedule_job(jobtype, data=None, priority=0, queue="default"):
def cancel_job(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)
query('UPDATE jobs SET canceled = true WHERE id = ?', job_id)
def restart_job(job_id, canceled=False):
if canceled:
query('UPDATE jobs SET state = \'ready\', canceled = 0 WHERE id = ? AND state = \'failed\'', job_id)
query('UPDATE jobs SET state = \'ready\', canceled = false WHERE id = ? AND state = \'failed\'', job_id)
else:
query('UPDATE jobs SET state = \'ready\' WHERE id = ? AND state = \'failed\' AND NOT canceled', job_id)
......@@ -57,7 +57,7 @@ def jobs_action(action, jobid=None):
if action == 'clear_failed':
query('UPDATE jobs SET state = \'deleted\' WHERE state = \'failed\' AND (id = ? OR ? IS NULL)', jobid, jobid)
elif action == 'retry_failed':
query('UPDATE jobs SET state = \'ready\', canceled = 0 WHERE state = \'failed\' AND (id = ? OR ? IS NULL)', jobid, jobid)
query('UPDATE jobs SET state = \'ready\', canceled = false WHERE state = \'failed\' AND (id = ? OR ? IS NULL)', jobid, jobid)
elif action == 'copy' and jobid:
query("INSERT INTO jobs (type, priority, queue, state, data, time_created) \
SELECT type, priority, queue, 'ready', data, ? FROM jobs where id = ?",
......
......@@ -45,21 +45,21 @@ def streamauth_legacy(server=None):
if 'lecture' in request.values:
match = {'id': request.values['lecture']}
try:
modify("INSERT INTO streams (handle, active, visible, lecture_id, description, poster) VALUES (?, 0, 1, -1, '', '')", request.values['name'])
modify("INSERT INTO streams (handle, active, visible, lecture_id, description, poster) VALUES (?, false, true, -1, '', '')", request.values['name'])
except:
pass
if server:
data = {'src': 'rtmp://%s/live/%s'%(server, request.values['name']),
'destbase': 'rtmp://%s/hls/%s'%(server, request.values['name'])}
job_id = schedule_job('simple_live_transcode', data, priority=10)
modify("UPDATE streams SET active = 1, lecture_id = ?, job_id = ? WHERE handle = ?",
modify("UPDATE streams SET active = true, lecture_id = ?, job_id = ? WHERE handle = ?",
match['id'], job_id, request.values['name'])
else:
modify("UPDATE streams SET active = 1, lecture_id = ? WHERE handle = ?",
modify("UPDATE streams SET active = true, lecture_id = ? WHERE handle = ?",
match['id'], request.values['name'])
elif request.values['call'] == 'publish_done':
job_id = query('SELECT job_id FROM streams WHERE handle = ?', request.values['name'])[0]['job_id']
modify("UPDATE streams SET active = 0 WHERE handle = ?", request.values['name'])
modify("UPDATE streams SET active = false WHERE handle = ?", request.values['name'])
if job_id:
cancel_job(job_id)
else:
......
......@@ -31,5 +31,5 @@ def update_meeting():
human_date(start), human_time(start))
modify('''REPLACE INTO announcements
(extid, text, level, visible, time_publish, time_expire, time_created, time_updated, created_by)
VALUES (?, ?, 0, 1, ?, ?, ?, ?, 0)''',
VALUES (?, ?, 0, true, ?, ?, ?, ?, 0)''',
'ical:'+uid, text, start-timedelta(days=7), start+timedelta(hours=2), datetime.now(), datetime.now())
......@@ -524,7 +524,7 @@ def auth(): #pylint: disable=too-many-branches
if is_authorized:
try:
if not url_path.startswith('pub/hls/'):
modify('INSERT INTO log (id, "time", "date", video, source) VALUES (?, ?, ?, ?, 1)',
modify('INSERT INTO log (id, "time", "date", video, source) VALUES (?, ?, ?, ?, true)',
cookie, datetime.now(), datetime.combine(date.today(), time()), perms[0]['vid'])
elif url_path.endswith('.ts'):
fmt = url_path.split('_')[-1].split('-')[0]
......
......@@ -14,7 +14,7 @@ class JobmanagementTestCase(FlaskTestCase):
return data[0]['count']
def getCanceledJobCount(self):
data = query("SELECT count(id) AS count from jobs WHERE canceled=1")
data = query("SELECT count(id) AS count from jobs WHERE canceled=true")
return data[0]['count']
def generateTestJob(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment