From bef234fd747899fa13cc33fc25e0d7458f36b97f Mon Sep 17 00:00:00 2001 From: broquemonsieur Date: Wed, 14 Jun 2023 22:53:02 -0700 Subject: [PATCH] Add compilations to DB --- config/sql/compilations.sql | 17 +++-------------- docker/init-invidious-db.sh | 2 ++ src/invidious/database/compilations.cr | 8 +++----- 3 files changed, 8 insertions(+), 19 deletions(-) diff --git a/config/sql/compilations.sql b/config/sql/compilations.sql index ccf04c30b..4076e1b8d 100644 --- a/config/sql/compilations.sql +++ b/config/sql/compilations.sql @@ -1,19 +1,8 @@ --- Type: public.privacy +-- Table: public.compilations --- DROP TYPE public.privacy; +-- DROP TABLE public.compilations; -CREATE TYPE public.privacy AS ENUM -( - 'Public', - 'Unlisted', - 'Private' -); - --- Table: public.playlists - --- DROP TABLE public.playlists; - -CREATE TABLE IF NOT EXISTS public.playlists +CREATE TABLE IF NOT EXISTS public.compilations ( title text, id text primary key, diff --git a/docker/init-invidious-db.sh b/docker/init-invidious-db.sh index 22b4cc5fd..f7fe3e7ff 100755 --- a/docker/init-invidious-db.sh +++ b/docker/init-invidious-db.sh @@ -10,3 +10,5 @@ psql --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" < config/sql/nonces.sql psql --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" < config/sql/annotations.sql psql --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" < config/sql/playlists.sql psql --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" < config/sql/playlist_videos.sql +psql --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" < config/sql/compilations.sql +psql --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" < config/sql/compilation_videos.sql diff --git a/src/invidious/database/compilations.cr b/src/invidious/database/compilations.cr index c6754a1ef..80672abfb 100644 --- a/src/invidious/database/compilations.cr +++ b/src/invidious/database/compilations.cr @@ -3,7 +3,7 @@ require "./base.cr" # # This module contains functions related to the "playlists" table. # -module Invidious::Database::Playlists +module Invidious::Database::Compilations extend self # ------------------- @@ -173,16 +173,14 @@ end # # This module contains functions related to the "playlist_videos" table. # -module Invidious::Database::PlaylistVideos +module Invidious::Database::CompilationVideos extend self - private alias VideoIndex = Int64 | Array(Int64) - # ------------------- # Insert / Delete # ------------------- - def insert(video : PlaylistVideo) + def insert(video : CompilationVideo) video_array = video.to_a request = <<-SQL