diff --git a/DATABASE.md b/DATABASE.md index 75e649e..938f3d0 100644 --- a/DATABASE.md +++ b/DATABASE.md @@ -165,7 +165,7 @@ Edit input values are initially NULL, but must not be NULL once the state is no columns | type | role | description -------------------------- | ---------------------------------- | :---------: | ----------- -`id` | `UUID PRIMARY KEY` | sheet input | Generated and attached to rows in the sheet to uniquely identify them even in the face of added, deleted or moved rows. +`id` | `TEXT PRIMARY KEY` | sheet input | Generated and attached to rows in the sheet to uniquely identify them even in the face of added, deleted or moved rows. `sheet_name` | `TEXT NOT NULL` | sheet input | The name of the worksheet that the row is on. This is used to tag videos, and can be used to narrow down the range to look for an id in for more efficient lookup (though we never do that right now). `event_start`, `event_end` | `TIMESTAMP` | sheet input | Start and end time of the event. Parsed from the sheet into timestamps or NULL. Used to set the editor time span, and displayed on the public sheet. The start time also determines what "day" the event lies on, for video tagging and other purposes. `category` | `TEXT NOT NULL DEFAULT ''` | sheet input | The kind of event. By convention selected from a small list of categories, but stored as an arbitrary string because there's little to no benefit to using an enum here, it just makes our job harder when adding a new category. Used to tag videos, and for display on the public sheet. diff --git a/cutter/cutter/main.py b/cutter/cutter/main.py index 1ce728f..4aabeb3 100644 --- a/cutter/cutter/main.py +++ b/cutter/cutter/main.py @@ -690,7 +690,7 @@ class TranscodeChecker(object): result = query(self.conn, """ UPDATE events SET state = 'DONE', upload_time = %s - WHERE id = ANY (%s::uuid[]) AND state = 'TRANSCODING' + WHERE id = ANY (%s) AND state = 'TRANSCODING' """, datetime.datetime.utcnow(), list(ids.keys())) return result.rowcount diff --git a/postgres/setup.sh b/postgres/setup.sh index 22bbca3..0dc0b2c 100644 --- a/postgres/setup.sh +++ b/postgres/setup.sh @@ -65,7 +65,7 @@ CREATE TYPE thumbnail_mode as ENUM ( ); CREATE TABLE events ( - id UUID PRIMARY KEY, + id TEXT PRIMARY KEY, sheet_name TEXT NOT NULL, event_start TIMESTAMP, diff --git a/sheetsync/sheetsync/main.py b/sheetsync/sheetsync/main.py index 832fc26..a948688 100644 --- a/sheetsync/sheetsync/main.py +++ b/sheetsync/sheetsync/main.py @@ -10,7 +10,7 @@ import gevent.event import prometheus_client as prom from monotonic import monotonic from psycopg2 import sql -from psycopg2.extras import register_uuid, execute_values +from psycopg2.extras import execute_values from requests import HTTPError import common @@ -352,8 +352,6 @@ def main(dbconnect, sheets_creds_file, edit_url, bustime_start, sheet_id, worksh common.install_stacksampler() prom.start_http_server(metrics_port) - register_uuid() - if backdoor_port: gevent.backdoor.BackdoorServer(('127.0.0.1', backdoor_port), locals=locals()).start() diff --git a/sheetsync/sheetsync/sheets.py b/sheetsync/sheetsync/sheets.py index 5bd5d08..7252296 100644 --- a/sheetsync/sheetsync/sheets.py +++ b/sheetsync/sheetsync/sheets.py @@ -120,7 +120,7 @@ class SheetsMiddleware(): 'poster_moment': lambda v: v == '[\u2713]', # check mark 'image_links': lambda v: [link.strip() for link in v.split()] if v.strip() else [], 'tags': lambda v: [tag.strip() for tag in v.split(',') if tag.strip()], - 'id': lambda v: uuid.UUID(v) if v.strip() else None, + 'id': lambda v: v if v.strip() else None, } # tracks when to do inactive checks self.sync_count = 0 @@ -175,7 +175,7 @@ class SheetsMiddleware(): logging.warning(f"Row {worksheet!r}:{row['index']} has no valid id, skipping") continue # Otherwise, allocate id for a new row. - row['id'] = uuid.uuid4() + row['id'] = str(uuid.uuid4()) logging.info(f"Allocating id for row {worksheet!r}:{row['index']} = {row['id']}") self.sheets.write_value( self.sheet_id, worksheet, diff --git a/thrimshim/thrimshim/main.py b/thrimshim/thrimshim/main.py index 514fd74..9a25813 100644 --- a/thrimshim/thrimshim/main.py +++ b/thrimshim/thrimshim/main.py @@ -22,7 +22,6 @@ from common.flask_stats import request_stats, after_request import google.oauth2.id_token import google.auth.transport.requests -psycopg2.extras.register_uuid() app = flask.Flask('thrimshim') app.after_request(after_request) @@ -145,7 +144,7 @@ def get_defaults(): }) -@app.route('/thrimshim/', methods=['GET']) +@app.route('/thrimshim/', methods=['GET']) @request_stats def get_row(ident): """Gets the row from the database with id == ident.""" @@ -242,7 +241,7 @@ def get_row(ident): return json.dumps(response, default=convert) -@app.route('/thrimshim/', methods=['POST']) +@app.route('/thrimshim/', methods=['POST']) @request_stats @authenticate def update_row(ident, editor=None): @@ -450,7 +449,7 @@ def update_row(ident, editor=None): return '' -@app.route('/thrimshim/manual-link/', methods=['POST']) +@app.route('/thrimshim/manual-link/', methods=['POST']) @request_stats @authenticate def manual_link(ident, editor=None): @@ -493,7 +492,7 @@ def manual_link(ident, editor=None): return '' -@app.route('/thrimshim/reset/', methods=['POST']) +@app.route('/thrimshim/reset/', methods=['POST']) @request_stats @authenticate def reset_row(ident, editor=None):