From 8dd6741ee9c2bb9e6282ea1b475bb943ba1bd26e Mon Sep 17 00:00:00 2001 From: Mike Lang Date: Fri, 16 Aug 2024 02:47:25 +1000 Subject: [PATCH] schema: Playlist tags may be null, indicating "match nothing" This is intended for partially-entered playlist data where tags have not been specified yet. --- playlist_manager/playlist_manager/main.py | 2 +- postgres/setup.sh | 5 +++-- thrimshim/thrimshim/main.py | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/playlist_manager/playlist_manager/main.py b/playlist_manager/playlist_manager/main.py index a5ff5ec..23eec5e 100644 --- a/playlist_manager/playlist_manager/main.py +++ b/playlist_manager/playlist_manager/main.py @@ -110,7 +110,7 @@ class PlaylistManager(object): [tag.lower() for tag in row.tags], row.first_event_id, row.last_event_id, - ) for row in query(conn, "SELECT playlist_id, tags, first_event_id, last_event_id FROM playlists") + ) for row in query(conn, "SELECT playlist_id, tags, first_event_id, last_event_id FROM playlists WHERE tags IS NOT NULL") } self.dbmanager.put_conn(conn) duplicates = set(playlists) & set(self.static_playlists) diff --git a/postgres/setup.sh b/postgres/setup.sh index 0dc0b2c..2495c50 100644 --- a/postgres/setup.sh +++ b/postgres/setup.sh @@ -142,11 +142,12 @@ CREATE TABLE editors ( ); -- Playlists are communicated to playlist manager via this table. --- Sheetsync will wipe and re-populate this table periodically to match what is in the sheet CREATE TABLE playlists ( playlist_id TEXT PRIMARY KEY, name TEXT NOT NULL, - tags TEXT[] NOT NULL, + -- When tags is NULL, it indicates tags have not been set and so the playlist should + -- match nothing. Conversely, when tags is empty, it indicates the playlist should match everything. + tags TEXT[], first_event_id UUID REFERENCES events(id) ON DELETE SET NULL, last_event_id UUID REFERENCES events(id) ON DELETE SET NULL, show_in_description BOOLEAN NOT NULL diff --git a/thrimshim/thrimshim/main.py b/thrimshim/thrimshim/main.py index 9a25813..6129f9b 100644 --- a/thrimshim/thrimshim/main.py +++ b/thrimshim/thrimshim/main.py @@ -303,7 +303,7 @@ def update_row(ident, editor=None): playlists = database.query(conn, """ SELECT playlist_id, name, tags FROM playlists - WHERE show_in_description + WHERE show_in_description AND tags IS NOT NULL """) # Filter for matching playlists for this video playlists = [