Added editor, edit_time and upload_time to thrimshim and cutter updates of the

database
pull/73/head^2
Christopher Usher 5 years ago
parent 75cafdabb7
commit 23e3cfce20

@ -57,7 +57,7 @@ CREATE TABLE IF NOT EXISTS events (
video_link TEXT CHECK (state != 'DONE' OR video_link IS NOT NULL), video_link TEXT CHECK (state != 'DONE' OR video_link IS NOT NULL),
editor TEXT CHECK (state = 'UNEDITED' OR editor IS NOT NULL), editor TEXT CHECK (state = 'UNEDITED' OR editor IS NOT NULL),
edit_time TIMESTAMP CHECK (state = 'UNEDITED' OR editor IS NOT NULL), edit_time TIMESTAMP CHECK (state = 'UNEDITED' OR editor IS NOT NULL),
upload_time TIMESTAMP CHECK (state != 'DONE' OR upload_time IS NOT NULL), upload_time TIMESTAMP CHECK (state != 'DONE' OR upload_time IS NOT NULL)
); );

@ -1,4 +1,5 @@
import datetime
import json import json
import logging import logging
import os import os
@ -461,9 +462,9 @@ class TranscodeChecker(object):
def mark_done(self, ids): def mark_done(self, ids):
result = query(self.conn, """ result = query(self.conn, """
UPDATE events UPDATE events
SET state = 'DONE' SET state = 'DONE', upload_time = %s
WHERE id = ANY (%s::uuid[]) AND state = 'TRANSCODING' WHERE id = ANY (%s::uuid[]) AND state = 'TRANSCODING'
""", ids.keys()) """, datetime.datetime.utcnow(), ids.keys())
return result.rowcount return result.rowcount

@ -151,6 +151,9 @@ def update_row(ident, new_row):
return 'Invalid state {}'.format(new_row['state']), 400 return 'Invalid state {}'.format(new_row['state']), 400
new_row['uploader'] = None new_row['uploader'] = None
new_row['error'] = None new_row['error'] = None
editor = '' # TODO replace with email form authentication
new_row['editor'] = editor
new_row['edit_time'] = datetime.datetime.utcnow()
# actually update database # actually update database
build_query = sql.SQL(""" build_query = sql.SQL("""
@ -186,12 +189,14 @@ def manual_link(ident):
return 'Row {} not found'.format(ident), 404 return 'Row {} not found'.format(ident), 404
if old_row.state != 'UNEDITED' and not (old_row.state == 'DONE' and old_row.upload_location == 'manual'): if old_row.state != 'UNEDITED' and not (old_row.state == 'DONE' and old_row.upload_location == 'manual'):
return 'Invalid state {} for manual video link'.format(old_row.state), 403 return 'Invalid state {} for manual video link'.format(old_row.state), 403
editor = '' # TODO replace with email form authentication
now = datetime.datetime.utcnow()
results = database.query(conn, """ results = database.query(conn, """
UPDATE events UPDATE events
SET state='DONE', upload_location = 'manual', video_link = %s SET state='DONE', upload_location = 'manual', video_link = %s,
editor = %s, edit_time = %s, upload_time = %s
WHERE id = %s AND (state = 'UNEDITED' OR (state = 'DONE' AND WHERE id = %s AND (state = 'UNEDITED' OR (state = 'DONE' AND
upload_location = 'manual'))""", link, ident) upload_location = 'manual'))""", link, editor, now, now, ident)
logging.info("Row {} video_link set to {}".format(ident, link)) logging.info("Row {} video_link set to {}".format(ident, link))
return '' return ''
@ -204,7 +209,7 @@ def reset_row(ident):
results = database.query(conn, """ results = database.query(conn, """
UPDATE events UPDATE events
SET state='UNEDITED', error = NULL, video_id = NULL, video_link = NULL, SET state='UNEDITED', error = NULL, video_id = NULL, video_link = NULL,
uploader = NULL uploader = NULL, editor = NULL, edit_time = NULL, upload_time = NULL
WHERE id = %s""", ident) WHERE id = %s""", ident)
if results.rowcount != 1: if results.rowcount != 1:
return 'Row id = {} not found'.format(ident), 404 return 'Row id = {} not found'.format(ident), 404

Loading…
Cancel
Save