diff --git a/spec/invidious/user/imports_spec.cr b/spec/invidious/user/imports_spec.cr index 762ce0d89..58b5d4aab 100644 --- a/spec/invidious/user/imports_spec.cr +++ b/spec/invidious/user/imports_spec.cr @@ -8,21 +8,21 @@ end def csv_sample return <<-CSV - Kanal-ID,Kanal-URL,Kanaltitel - UC0hHW5Y08ggq-9kbrGgWj0A,http://www.youtube.com/channel/UC0hHW5Y08ggq-9kbrGgWj0A,Matias Marolla - UC0vBXGSyV14uvJ4hECDOl0Q,http://www.youtube.com/channel/UC0vBXGSyV14uvJ4hECDOl0Q,Techquickie - UC1sELGmy5jp5fQUugmuYlXQ,http://www.youtube.com/channel/UC1sELGmy5jp5fQUugmuYlXQ,Minecraft - UC9kFnwdCRrX7oTjqKd6-tiQ,http://www.youtube.com/channel/UC9kFnwdCRrX7oTjqKd6-tiQ,LUMOX - Topic - UCBa659QWEk1AI4Tg--mrJ2A,http://www.youtube.com/channel/UCBa659QWEk1AI4Tg--mrJ2A,Tom Scott - UCGu6_XQ64rXPR6nuitMQE_A,http://www.youtube.com/channel/UCGu6_XQ64rXPR6nuitMQE_A,Callcenter Fun - UCGwu0nbY2wSkW8N-cghnLpA,http://www.youtube.com/channel/UCGwu0nbY2wSkW8N-cghnLpA,Jaiden Animations - UCQ0OvZ54pCFZwsKxbltg_tg,http://www.youtube.com/channel/UCQ0OvZ54pCFZwsKxbltg_tg,Methos - UCRE6itj4Jte4manQEu3Y7OA,http://www.youtube.com/channel/UCRE6itj4Jte4manQEu3Y7OA,Chipflake - UCRLc6zsv_d0OEBO8OOkz-DA,http://www.youtube.com/channel/UCRLc6zsv_d0OEBO8OOkz-DA,Kegy - UCSl5Uxu2LyaoAoMMGp6oTJA,http://www.youtube.com/channel/UCSl5Uxu2LyaoAoMMGp6oTJA,Atomic Shrimp - UCXuqSBlHAE6Xw-yeJA0Tunw,http://www.youtube.com/channel/UCXuqSBlHAE6Xw-yeJA0Tunw,Linus Tech Tips - UCZ5XnGb-3t7jCkXdawN2tkA,http://www.youtube.com/channel/UCZ5XnGb-3t7jCkXdawN2tkA,Discord - CSV + Kanal-ID,Kanal-URL,Kanaltitel + UC0hHW5Y08ggq-9kbrGgWj0A,http://www.youtube.com/channel/UC0hHW5Y08ggq-9kbrGgWj0A,Matias Marolla + UC0vBXGSyV14uvJ4hECDOl0Q,http://www.youtube.com/channel/UC0vBXGSyV14uvJ4hECDOl0Q,Techquickie + UC1sELGmy5jp5fQUugmuYlXQ,http://www.youtube.com/channel/UC1sELGmy5jp5fQUugmuYlXQ,Minecraft + UC9kFnwdCRrX7oTjqKd6-tiQ,http://www.youtube.com/channel/UC9kFnwdCRrX7oTjqKd6-tiQ,LUMOX - Topic + UCBa659QWEk1AI4Tg--mrJ2A,http://www.youtube.com/channel/UCBa659QWEk1AI4Tg--mrJ2A,Tom Scott + UCGu6_XQ64rXPR6nuitMQE_A,http://www.youtube.com/channel/UCGu6_XQ64rXPR6nuitMQE_A,Callcenter Fun + UCGwu0nbY2wSkW8N-cghnLpA,http://www.youtube.com/channel/UCGwu0nbY2wSkW8N-cghnLpA,Jaiden Animations + UCQ0OvZ54pCFZwsKxbltg_tg,http://www.youtube.com/channel/UCQ0OvZ54pCFZwsKxbltg_tg,Methos + UCRE6itj4Jte4manQEu3Y7OA,http://www.youtube.com/channel/UCRE6itj4Jte4manQEu3Y7OA,Chipflake + UCRLc6zsv_d0OEBO8OOkz-DA,http://www.youtube.com/channel/UCRLc6zsv_d0OEBO8OOkz-DA,Kegy + UCSl5Uxu2LyaoAoMMGp6oTJA,http://www.youtube.com/channel/UCSl5Uxu2LyaoAoMMGp6oTJA,Atomic Shrimp + UCXuqSBlHAE6Xw-yeJA0Tunw,http://www.youtube.com/channel/UCXuqSBlHAE6Xw-yeJA0Tunw,Linus Tech Tips + UCZ5XnGb-3t7jCkXdawN2tkA,http://www.youtube.com/channel/UCZ5XnGb-3t7jCkXdawN2tkA,Discord + CSV end Spectator.describe Invidious::User::Import do diff --git a/src/invidious/database/annotations.cr b/src/invidious/database/annotations.cr index 037494730..f1659509a 100644 --- a/src/invidious/database/annotations.cr +++ b/src/invidious/database/annotations.cr @@ -8,7 +8,7 @@ module Invidious::Database::Annotations INSERT INTO annotations VALUES ($1, $2) ON CONFLICT DO NOTHING - SQL + SQL PG_DB.exec(request, id, annotations) end @@ -17,7 +17,7 @@ module Invidious::Database::Annotations request = <<-SQL SELECT * FROM annotations WHERE id = $1 - SQL + SQL return PG_DB.query_one?(request, id, as: Annotation) end diff --git a/src/invidious/database/channels.cr b/src/invidious/database/channels.cr index df44e485d..3e7f480ce 100644 --- a/src/invidious/database/channels.cr +++ b/src/invidious/database/channels.cr @@ -16,13 +16,13 @@ module Invidious::Database::Channels request = <<-SQL INSERT INTO channels VALUES (#{arg_array(channel_array)}) - SQL + SQL if update_on_conflict request += <<-SQL ON CONFLICT (id) DO UPDATE SET author = $2, updated = $3 - SQL + SQL end PG_DB.exec(request, args: channel_array) @@ -37,7 +37,7 @@ module Invidious::Database::Channels UPDATE channels SET updated = now(), author = $1, deleted = false WHERE id = $2 - SQL + SQL PG_DB.exec(request, author, id) end @@ -47,7 +47,7 @@ module Invidious::Database::Channels UPDATE channels SET subscribed = now() WHERE id = $1 - SQL + SQL PG_DB.exec(request, id) end @@ -57,7 +57,7 @@ module Invidious::Database::Channels UPDATE channels SET updated = now(), deleted = true WHERE id = $1 - SQL + SQL PG_DB.exec(request, id) end @@ -70,7 +70,7 @@ module Invidious::Database::Channels request = <<-SQL SELECT * FROM channels WHERE id = $1 - SQL + SQL return PG_DB.query_one?(request, id, as: InvidiousChannel) end @@ -81,7 +81,7 @@ module Invidious::Database::Channels request = <<-SQL SELECT * FROM channels WHERE id = ANY($1) - SQL + SQL return PG_DB.query_all(request, ids, as: InvidiousChannel) end @@ -112,7 +112,7 @@ module Invidious::Database::ChannelVideos SET title = $2, published = $3, updated = $4, ucid = $5, author = $6, length_seconds = $7, live_now = $8, #{last_items} RETURNING (xmax=0) AS was_insert - SQL + SQL return PG_DB.query_one(request, *video.to_tuple, as: Bool) end @@ -128,7 +128,7 @@ module Invidious::Database::ChannelVideos SELECT * FROM channel_videos WHERE id = ANY($1) ORDER BY published DESC - SQL + SQL return PG_DB.query_all(request, ids, as: ChannelVideo) end @@ -139,7 +139,7 @@ module Invidious::Database::ChannelVideos WHERE ucid = $1 AND published > $2 ORDER BY published DESC LIMIT 15 - SQL + SQL return PG_DB.query_all(request, ucid, since, as: ChannelVideo) end @@ -151,7 +151,7 @@ module Invidious::Database::ChannelVideos WHERE ucid IN (SELECT channel FROM (SELECT UNNEST(subscriptions) AS channel FROM users) AS d GROUP BY channel ORDER BY COUNT(channel) DESC LIMIT 40) ORDER BY ucid, published DESC - SQL + SQL PG_DB.query_all(request, as: ChannelVideo) end diff --git a/src/invidious/database/migrations/0001_create_channels_table.cr b/src/invidious/database/migrations/0001_create_channels_table.cr index a1362bcf8..df7e31a12 100644 --- a/src/invidious/database/migrations/0001_create_channels_table.cr +++ b/src/invidious/database/migrations/0001_create_channels_table.cr @@ -4,27 +4,27 @@ module Invidious::Database::Migrations def up(conn : DB::Connection) conn.exec <<-SQL - CREATE TABLE IF NOT EXISTS public.channels - ( - id text NOT NULL, - author text, - updated timestamp with time zone, - deleted boolean, - subscribed timestamp with time zone, - CONSTRAINT channels_id_key UNIQUE (id) - ); - SQL + CREATE TABLE IF NOT EXISTS public.channels + ( + id text NOT NULL, + author text, + updated timestamp with time zone, + deleted boolean, + subscribed timestamp with time zone, + CONSTRAINT channels_id_key UNIQUE (id) + ); + SQL conn.exec <<-SQL - GRANT ALL ON TABLE public.channels TO current_user; - SQL + GRANT ALL ON TABLE public.channels TO current_user; + SQL conn.exec <<-SQL - CREATE INDEX IF NOT EXISTS channels_id_idx - ON public.channels - USING btree - (id COLLATE pg_catalog."default"); - SQL + CREATE INDEX IF NOT EXISTS channels_id_idx + ON public.channels + USING btree + (id COLLATE pg_catalog."default"); + SQL end end end diff --git a/src/invidious/database/migrations/0002_create_videos_table.cr b/src/invidious/database/migrations/0002_create_videos_table.cr index c2ac84f8f..1d0f5afb6 100644 --- a/src/invidious/database/migrations/0002_create_videos_table.cr +++ b/src/invidious/database/migrations/0002_create_videos_table.cr @@ -4,25 +4,25 @@ module Invidious::Database::Migrations def up(conn : DB::Connection) conn.exec <<-SQL - CREATE UNLOGGED TABLE IF NOT EXISTS public.videos - ( - id text NOT NULL, - info text, - updated timestamp with time zone, - CONSTRAINT videos_pkey PRIMARY KEY (id) - ); - SQL + CREATE UNLOGGED TABLE IF NOT EXISTS public.videos + ( + id text NOT NULL, + info text, + updated timestamp with time zone, + CONSTRAINT videos_pkey PRIMARY KEY (id) + ); + SQL conn.exec <<-SQL - GRANT ALL ON TABLE public.videos TO current_user; - SQL + GRANT ALL ON TABLE public.videos TO current_user; + SQL conn.exec <<-SQL - CREATE UNIQUE INDEX IF NOT EXISTS id_idx - ON public.videos - USING btree - (id COLLATE pg_catalog."default"); - SQL + CREATE UNIQUE INDEX IF NOT EXISTS id_idx + ON public.videos + USING btree + (id COLLATE pg_catalog."default"); + SQL end end end diff --git a/src/invidious/database/migrations/0003_create_channel_videos_table.cr b/src/invidious/database/migrations/0003_create_channel_videos_table.cr index c9b62e4c6..e4023fefe 100644 --- a/src/invidious/database/migrations/0003_create_channel_videos_table.cr +++ b/src/invidious/database/migrations/0003_create_channel_videos_table.cr @@ -4,32 +4,32 @@ module Invidious::Database::Migrations def up(conn : DB::Connection) conn.exec <<-SQL - CREATE TABLE IF NOT EXISTS public.channel_videos - ( - id text NOT NULL, - title text, - published timestamp with time zone, - updated timestamp with time zone, - ucid text, - author text, - length_seconds integer, - live_now boolean, - premiere_timestamp timestamp with time zone, - views bigint, - CONSTRAINT channel_videos_id_key UNIQUE (id) - ); - SQL + CREATE TABLE IF NOT EXISTS public.channel_videos + ( + id text NOT NULL, + title text, + published timestamp with time zone, + updated timestamp with time zone, + ucid text, + author text, + length_seconds integer, + live_now boolean, + premiere_timestamp timestamp with time zone, + views bigint, + CONSTRAINT channel_videos_id_key UNIQUE (id) + ); + SQL conn.exec <<-SQL - GRANT ALL ON TABLE public.channel_videos TO current_user; - SQL + GRANT ALL ON TABLE public.channel_videos TO current_user; + SQL conn.exec <<-SQL - CREATE INDEX IF NOT EXISTS channel_videos_ucid_idx - ON public.channel_videos - USING btree - (ucid COLLATE pg_catalog."default"); - SQL + CREATE INDEX IF NOT EXISTS channel_videos_ucid_idx + ON public.channel_videos + USING btree + (ucid COLLATE pg_catalog."default"); + SQL end end end diff --git a/src/invidious/database/migrations/0004_create_users_table.cr b/src/invidious/database/migrations/0004_create_users_table.cr index a13ba15f0..3e561bc04 100644 --- a/src/invidious/database/migrations/0004_create_users_table.cr +++ b/src/invidious/database/migrations/0004_create_users_table.cr @@ -4,31 +4,31 @@ module Invidious::Database::Migrations def up(conn : DB::Connection) conn.exec <<-SQL - CREATE TABLE IF NOT EXISTS public.users - ( - updated timestamp with time zone, - notifications text[], - subscriptions text[], - email text NOT NULL, - preferences text, - password text, - token text, - watched text[], - feed_needs_update boolean, - CONSTRAINT users_email_key UNIQUE (email) - ); - SQL + CREATE TABLE IF NOT EXISTS public.users + ( + updated timestamp with time zone, + notifications text[], + subscriptions text[], + email text NOT NULL, + preferences text, + password text, + token text, + watched text[], + feed_needs_update boolean, + CONSTRAINT users_email_key UNIQUE (email) + ); + SQL conn.exec <<-SQL - GRANT ALL ON TABLE public.users TO current_user; - SQL + GRANT ALL ON TABLE public.users TO current_user; + SQL conn.exec <<-SQL - CREATE UNIQUE INDEX IF NOT EXISTS email_unique_idx - ON public.users - USING btree - (lower(email) COLLATE pg_catalog."default"); - SQL + CREATE UNIQUE INDEX IF NOT EXISTS email_unique_idx + ON public.users + USING btree + (lower(email) COLLATE pg_catalog."default"); + SQL end end end diff --git a/src/invidious/database/migrations/0005_create_session_ids_table.cr b/src/invidious/database/migrations/0005_create_session_ids_table.cr index 13c2228d1..e760ad166 100644 --- a/src/invidious/database/migrations/0005_create_session_ids_table.cr +++ b/src/invidious/database/migrations/0005_create_session_ids_table.cr @@ -4,25 +4,25 @@ module Invidious::Database::Migrations def up(conn : DB::Connection) conn.exec <<-SQL - CREATE TABLE IF NOT EXISTS public.session_ids - ( - id text NOT NULL, - email text, - issued timestamp with time zone, - CONSTRAINT session_ids_pkey PRIMARY KEY (id) - ); - SQL + CREATE TABLE IF NOT EXISTS public.session_ids + ( + id text NOT NULL, + email text, + issued timestamp with time zone, + CONSTRAINT session_ids_pkey PRIMARY KEY (id) + ); + SQL conn.exec <<-SQL - GRANT ALL ON TABLE public.session_ids TO current_user; - SQL + GRANT ALL ON TABLE public.session_ids TO current_user; + SQL conn.exec <<-SQL - CREATE INDEX IF NOT EXISTS session_ids_id_idx - ON public.session_ids - USING btree - (id COLLATE pg_catalog."default"); - SQL + CREATE INDEX IF NOT EXISTS session_ids_id_idx + ON public.session_ids + USING btree + (id COLLATE pg_catalog."default"); + SQL end end end diff --git a/src/invidious/database/migrations/0006_create_nonces_table.cr b/src/invidious/database/migrations/0006_create_nonces_table.cr index cf1229e16..c2ae7a873 100644 --- a/src/invidious/database/migrations/0006_create_nonces_table.cr +++ b/src/invidious/database/migrations/0006_create_nonces_table.cr @@ -4,24 +4,24 @@ module Invidious::Database::Migrations def up(conn : DB::Connection) conn.exec <<-SQL - CREATE TABLE IF NOT EXISTS public.nonces - ( - nonce text, - expire timestamp with time zone, - CONSTRAINT nonces_id_key UNIQUE (nonce) - ); - SQL + CREATE TABLE IF NOT EXISTS public.nonces + ( + nonce text, + expire timestamp with time zone, + CONSTRAINT nonces_id_key UNIQUE (nonce) + ); + SQL conn.exec <<-SQL - GRANT ALL ON TABLE public.nonces TO current_user; - SQL + GRANT ALL ON TABLE public.nonces TO current_user; + SQL conn.exec <<-SQL - CREATE INDEX IF NOT EXISTS nonces_nonce_idx - ON public.nonces - USING btree - (nonce COLLATE pg_catalog."default"); - SQL + CREATE INDEX IF NOT EXISTS nonces_nonce_idx + ON public.nonces + USING btree + (nonce COLLATE pg_catalog."default"); + SQL end end end diff --git a/src/invidious/database/migrations/0007_create_annotations_table.cr b/src/invidious/database/migrations/0007_create_annotations_table.cr index dcecbc3b8..518e28860 100644 --- a/src/invidious/database/migrations/0007_create_annotations_table.cr +++ b/src/invidious/database/migrations/0007_create_annotations_table.cr @@ -4,17 +4,17 @@ module Invidious::Database::Migrations def up(conn : DB::Connection) conn.exec <<-SQL - CREATE TABLE IF NOT EXISTS public.annotations - ( - id text NOT NULL, - annotations xml, - CONSTRAINT annotations_id_key UNIQUE (id) - ); - SQL + CREATE TABLE IF NOT EXISTS public.annotations + ( + id text NOT NULL, + annotations xml, + CONSTRAINT annotations_id_key UNIQUE (id) + ); + SQL conn.exec <<-SQL - GRANT ALL ON TABLE public.annotations TO current_user; - SQL + GRANT ALL ON TABLE public.annotations TO current_user; + SQL end end end diff --git a/src/invidious/database/migrations/0008_create_playlists_table.cr b/src/invidious/database/migrations/0008_create_playlists_table.cr index 6aa16e1a9..63901f61d 100644 --- a/src/invidious/database/migrations/0008_create_playlists_table.cr +++ b/src/invidious/database/migrations/0008_create_playlists_table.cr @@ -5,33 +5,33 @@ module Invidious::Database::Migrations def up(conn : DB::Connection) if !privacy_type_exists?(conn) conn.exec <<-SQL - CREATE TYPE public.privacy AS ENUM - ( - 'Public', - 'Unlisted', - 'Private' - ); - SQL + CREATE TYPE public.privacy AS ENUM + ( + 'Public', + 'Unlisted', + 'Private' + ); + SQL end conn.exec <<-SQL - CREATE TABLE IF NOT EXISTS public.playlists - ( - title text, - id text primary key, - author text, - description text, - video_count integer, - created timestamptz, - updated timestamptz, - privacy privacy, - index int8[] - ); - SQL + CREATE TABLE IF NOT EXISTS public.playlists + ( + title text, + id text primary key, + author text, + description text, + video_count integer, + created timestamptz, + updated timestamptz, + privacy privacy, + index int8[] + ); + SQL conn.exec <<-SQL - GRANT ALL ON public.playlists TO current_user; - SQL + GRANT ALL ON public.playlists TO current_user; + SQL end private def privacy_type_exists?(conn : DB::Connection) : Bool @@ -42,7 +42,7 @@ module Invidious::Database::Migrations WHERE pg_namespace.nspname = 'public' AND pg_type.typname = 'privacy' LIMIT 1; - SQL + SQL !conn.query_one?(request, as: Int32).nil? end diff --git a/src/invidious/database/migrations/0009_create_playlist_videos_table.cr b/src/invidious/database/migrations/0009_create_playlist_videos_table.cr index 84938b9ba..82699b34b 100644 --- a/src/invidious/database/migrations/0009_create_playlist_videos_table.cr +++ b/src/invidious/database/migrations/0009_create_playlist_videos_table.cr @@ -4,24 +4,24 @@ module Invidious::Database::Migrations def up(conn : DB::Connection) conn.exec <<-SQL - CREATE TABLE IF NOT EXISTS public.playlist_videos - ( - title text, - id text, - author text, - ucid text, - length_seconds integer, - published timestamptz, - plid text references playlists(id), - index int8, - live_now boolean, - PRIMARY KEY (index,plid) - ); - SQL + CREATE TABLE IF NOT EXISTS public.playlist_videos + ( + title text, + id text, + author text, + ucid text, + length_seconds integer, + published timestamptz, + plid text references playlists(id), + index int8, + live_now boolean, + PRIMARY KEY (index,plid) + ); + SQL conn.exec <<-SQL - GRANT ALL ON TABLE public.playlist_videos TO current_user; - SQL + GRANT ALL ON TABLE public.playlist_videos TO current_user; + SQL end end end diff --git a/src/invidious/database/migrations/0010_make_videos_unlogged.cr b/src/invidious/database/migrations/0010_make_videos_unlogged.cr index f5d196834..37f1da234 100644 --- a/src/invidious/database/migrations/0010_make_videos_unlogged.cr +++ b/src/invidious/database/migrations/0010_make_videos_unlogged.cr @@ -4,8 +4,8 @@ module Invidious::Database::Migrations def up(conn : DB::Connection) conn.exec <<-SQL - ALTER TABLE public.videos SET UNLOGGED; - SQL + ALTER TABLE public.videos SET UNLOGGED; + SQL end end end diff --git a/src/invidious/database/migrator.cr b/src/invidious/database/migrator.cr index 660c32034..200cf421b 100644 --- a/src/invidious/database/migrator.cr +++ b/src/invidious/database/migrator.cr @@ -44,6 +44,6 @@ class Invidious::Database::Migrator id bigserial PRIMARY KEY, version bigint NOT NULL ) - SQL + SQL end end diff --git a/src/invidious/database/nonces.cr b/src/invidious/database/nonces.cr index b87c81ecb..55c8d8560 100644 --- a/src/invidious/database/nonces.cr +++ b/src/invidious/database/nonces.cr @@ -12,7 +12,7 @@ module Invidious::Database::Nonces INSERT INTO nonces VALUES ($1, $2) ON CONFLICT DO NOTHING - SQL + SQL PG_DB.exec(request, nonce, expire) end @@ -21,7 +21,7 @@ module Invidious::Database::Nonces request = <<-SQL DELETE FROM nonces * WHERE expire < now() - SQL + SQL PG_DB.exec(request) end @@ -35,7 +35,7 @@ module Invidious::Database::Nonces UPDATE nonces SET expire = $1 WHERE nonce = $2 - SQL + SQL PG_DB.exec(request, Time.utc(1990, 1, 1), nonce) end @@ -48,7 +48,7 @@ module Invidious::Database::Nonces request = <<-SQL SELECT * FROM nonces WHERE nonce = $1 - SQL + SQL return PG_DB.query_one?(request, nonce, as: {String, Time}) end diff --git a/src/invidious/database/playlists.cr b/src/invidious/database/playlists.cr index 6dbcaa051..ba1e5b0a8 100644 --- a/src/invidious/database/playlists.cr +++ b/src/invidious/database/playlists.cr @@ -16,7 +16,7 @@ module Invidious::Database::Playlists request = <<-SQL INSERT INTO playlists VALUES (#{arg_array(playlist_array)}) - SQL + SQL PG_DB.exec(request, args: playlist_array) end @@ -27,7 +27,7 @@ module Invidious::Database::Playlists request = <<-SQL DELETE FROM playlists * WHERE id = $1 - SQL + SQL PG_DB.exec(request, id) end @@ -41,7 +41,7 @@ module Invidious::Database::Playlists UPDATE playlists SET title = $1, privacy = $2, description = $3, updated = $4 WHERE id = $5 - SQL + SQL PG_DB.exec(request, title, privacy, description, updated, id) end @@ -51,7 +51,7 @@ module Invidious::Database::Playlists UPDATE playlists SET description = $1 WHERE id = $2 - SQL + SQL PG_DB.exec(request, description, id) end @@ -61,7 +61,7 @@ module Invidious::Database::Playlists UPDATE playlists SET subscribed = now() WHERE id = $1 - SQL + SQL PG_DB.exec(request, id) end @@ -73,7 +73,7 @@ module Invidious::Database::Playlists video_count = cardinality(index) + 1, updated = now() WHERE id = $2 - SQL + SQL PG_DB.exec(request, index, id) end @@ -85,7 +85,7 @@ module Invidious::Database::Playlists video_count = cardinality(index) - 1, updated = now() WHERE id = $2 - SQL + SQL PG_DB.exec(request, index, id) end @@ -98,7 +98,7 @@ module Invidious::Database::Playlists request = <<-SQL SELECT * FROM playlists WHERE id = $1 - SQL + SQL return PG_DB.query_one?(request, id, as: InvidiousPlaylist) end @@ -107,7 +107,7 @@ module Invidious::Database::Playlists request = <<-SQL SELECT * FROM playlists WHERE author = $1 - SQL + SQL return PG_DB.query_all(request, author, as: InvidiousPlaylist) end @@ -121,7 +121,7 @@ module Invidious::Database::Playlists SELECT * FROM playlists WHERE author = $1 AND id LIKE 'IV%' ORDER BY created - SQL + SQL PG_DB.query_all(request, email, as: InvidiousPlaylist) end @@ -131,7 +131,7 @@ module Invidious::Database::Playlists SELECT * FROM playlists WHERE author = $1 AND id NOT LIKE 'IV%' ORDER BY created - SQL + SQL PG_DB.query_all(request, email, as: InvidiousPlaylist) end @@ -141,7 +141,7 @@ module Invidious::Database::Playlists SELECT id,title FROM playlists WHERE author = $1 AND id LIKE 'IV%' ORDER BY title - SQL + SQL PG_DB.query_all(request, email, as: {String, String}) end @@ -155,7 +155,7 @@ module Invidious::Database::Playlists request = <<-SQL SELECT id FROM playlists WHERE id = $1 - SQL + SQL return PG_DB.query_one?(request, id, as: String).nil? end @@ -165,7 +165,7 @@ module Invidious::Database::Playlists request = <<-SQL SELECT count(*) FROM playlists WHERE author = $1 - SQL + SQL return PG_DB.query_one?(request, author, as: Int64) || 0_i64 end @@ -189,7 +189,7 @@ module Invidious::Database::PlaylistVideos request = <<-SQL INSERT INTO playlist_videos VALUES (#{arg_array(video_array)}) - SQL + SQL PG_DB.exec(request, args: video_array) end @@ -198,7 +198,7 @@ module Invidious::Database::PlaylistVideos request = <<-SQL DELETE FROM playlist_videos * WHERE index = $1 - SQL + SQL PG_DB.exec(request, index) end @@ -207,7 +207,7 @@ module Invidious::Database::PlaylistVideos request = <<-SQL DELETE FROM playlist_videos * WHERE plid = $1 - SQL + SQL PG_DB.exec(request, plid) end @@ -223,7 +223,7 @@ module Invidious::Database::PlaylistVideos ORDER BY array_position($2, index) LIMIT $3 OFFSET $4 - SQL + SQL return PG_DB.query_all(request, plid, index, limit, offset, as: PlaylistVideo) end @@ -233,7 +233,7 @@ module Invidious::Database::PlaylistVideos SELECT index FROM playlist_videos WHERE plid = $1 AND id = $2 LIMIT 1 - SQL + SQL return PG_DB.query_one?(request, plid, vid, as: Int64) end @@ -244,7 +244,7 @@ module Invidious::Database::PlaylistVideos WHERE plid = $1 ORDER BY array_position($2, index) LIMIT 1 - SQL + SQL return PG_DB.query_one?(request, plid, index, as: String) end @@ -255,7 +255,7 @@ module Invidious::Database::PlaylistVideos WHERE plid = $1 ORDER BY array_position($2, index) LIMIT $3 - SQL + SQL return PG_DB.query_all(request, plid, index, limit, as: String) end diff --git a/src/invidious/database/sessions.cr b/src/invidious/database/sessions.cr index 965870829..5537f087f 100644 --- a/src/invidious/database/sessions.cr +++ b/src/invidious/database/sessions.cr @@ -11,7 +11,7 @@ module Invidious::Database::SessionIDs request = <<-SQL INSERT INTO session_ids VALUES ($1, $2, now()) - SQL + SQL request += " ON CONFLICT (id) DO NOTHING" if handle_conflicts @@ -26,7 +26,7 @@ module Invidious::Database::SessionIDs request = <<-SQL DELETE FROM session_ids * WHERE id = $1 - SQL + SQL PG_DB.exec(request, sid) end @@ -35,7 +35,7 @@ module Invidious::Database::SessionIDs request = <<-SQL DELETE FROM session_ids * WHERE email = $1 - SQL + SQL PG_DB.exec(request, email) end @@ -44,7 +44,7 @@ module Invidious::Database::SessionIDs request = <<-SQL DELETE FROM session_ids * WHERE id = $1 AND email = $2 - SQL + SQL PG_DB.exec(request, sid, email) end @@ -57,7 +57,7 @@ module Invidious::Database::SessionIDs request = <<-SQL SELECT email FROM session_ids WHERE id = $1 - SQL + SQL PG_DB.query_one?(request, sid, as: String) end @@ -67,7 +67,7 @@ module Invidious::Database::SessionIDs SELECT id, issued FROM session_ids WHERE email = $1 ORDER BY issued DESC - SQL + SQL PG_DB.query_all(request, email, as: {session: String, issued: Time}) end diff --git a/src/invidious/database/statistics.cr b/src/invidious/database/statistics.cr index 9e4963fde..cf2a138e6 100644 --- a/src/invidious/database/statistics.cr +++ b/src/invidious/database/statistics.cr @@ -10,7 +10,7 @@ module Invidious::Database::Statistics def count_users_total : Int64 request = <<-SQL SELECT count(*) FROM users - SQL + SQL PG_DB.query_one(request, as: Int64) end @@ -19,7 +19,7 @@ module Invidious::Database::Statistics request = <<-SQL SELECT count(*) FROM users WHERE CURRENT_TIMESTAMP - updated < '6 months' - SQL + SQL PG_DB.query_one(request, as: Int64) end @@ -28,7 +28,7 @@ module Invidious::Database::Statistics request = <<-SQL SELECT count(*) FROM users WHERE CURRENT_TIMESTAMP - updated < '1 month' - SQL + SQL PG_DB.query_one(request, as: Int64) end @@ -42,7 +42,7 @@ module Invidious::Database::Statistics SELECT updated FROM channels ORDER BY updated DESC LIMIT 1 - SQL + SQL PG_DB.query_one?(request, as: Time) end diff --git a/src/invidious/database/users.cr b/src/invidious/database/users.cr index 4a3056ea5..9b297930f 100644 --- a/src/invidious/database/users.cr +++ b/src/invidious/database/users.cr @@ -14,13 +14,13 @@ module Invidious::Database::Users request = <<-SQL INSERT INTO users VALUES (#{arg_array(user_array)}) - SQL + SQL if update_on_conflict request += <<-SQL ON CONFLICT (email) DO UPDATE SET updated = $1, subscriptions = $3 - SQL + SQL end PG_DB.exec(request, args: user_array) @@ -30,7 +30,7 @@ module Invidious::Database::Users request = <<-SQL DELETE FROM users * WHERE email = $1 - SQL + SQL PG_DB.exec(request, user.email) end @@ -44,7 +44,7 @@ module Invidious::Database::Users UPDATE users SET watched = $1 WHERE email = $2 - SQL + SQL PG_DB.exec(request, user.watched, user.email) end @@ -54,7 +54,7 @@ module Invidious::Database::Users UPDATE users SET watched = array_append(array_remove(watched, $1), $1) WHERE email = $2 - SQL + SQL PG_DB.exec(request, vid, user.email) end @@ -64,7 +64,7 @@ module Invidious::Database::Users UPDATE users SET watched = array_remove(watched, $1) WHERE email = $2 - SQL + SQL PG_DB.exec(request, vid, user.email) end @@ -74,7 +74,7 @@ module Invidious::Database::Users UPDATE users SET watched = '{}' WHERE email = $1 - SQL + SQL PG_DB.exec(request, user.email) end @@ -88,7 +88,7 @@ module Invidious::Database::Users UPDATE users SET feed_needs_update = true, subscriptions = $1 WHERE email = $2 - SQL + SQL PG_DB.exec(request, user.subscriptions, user.email) end @@ -99,7 +99,7 @@ module Invidious::Database::Users SET feed_needs_update = true, subscriptions = array_append(subscriptions,$1) WHERE email = $2 - SQL + SQL PG_DB.exec(request, ucid, user.email) end @@ -110,7 +110,7 @@ module Invidious::Database::Users SET feed_needs_update = true, subscriptions = array_remove(subscriptions, $1) WHERE email = $2 - SQL + SQL PG_DB.exec(request, ucid, user.email) end @@ -125,7 +125,7 @@ module Invidious::Database::Users SET notifications = array_cat(notifications, $1), feed_needs_update = true WHERE $2 = ANY(subscriptions) - SQL + SQL PG_DB.exec(request, video_ids, channel_id) end @@ -135,7 +135,7 @@ module Invidious::Database::Users UPDATE users SET notifications = array_remove(notifications, $1) WHERE email = $2 - SQL + SQL PG_DB.exec(request, vid, user.email) end @@ -145,7 +145,7 @@ module Invidious::Database::Users UPDATE users SET notifications = '{}', updated = now() WHERE email = $1 - SQL + SQL PG_DB.exec(request, user.email) end @@ -159,7 +159,7 @@ module Invidious::Database::Users UPDATE users SET feed_needs_update = true WHERE $1 = ANY(subscriptions) - SQL + SQL PG_DB.exec(request, channel_id) end @@ -169,7 +169,7 @@ module Invidious::Database::Users UPDATE users SET preferences = $1 WHERE email = $2 - SQL + SQL PG_DB.exec(request, user.preferences.to_json, user.email) end @@ -179,7 +179,7 @@ module Invidious::Database::Users UPDATE users SET password = $1 WHERE email = $2 - SQL + SQL PG_DB.exec(request, pass, user.email) end @@ -192,7 +192,7 @@ module Invidious::Database::Users request = <<-SQL SELECT * FROM users WHERE email = $1 - SQL + SQL return PG_DB.query_one?(request, email, as: User) end @@ -202,7 +202,7 @@ module Invidious::Database::Users request = <<-SQL SELECT * FROM users WHERE email = $1 - SQL + SQL return PG_DB.query_one(request, email, as: User) end @@ -211,7 +211,7 @@ module Invidious::Database::Users request = <<-SQL SELECT * FROM users WHERE token = $1 - SQL + SQL return PG_DB.query_one?(request, token, as: User) end @@ -221,7 +221,7 @@ module Invidious::Database::Users SELECT notifications FROM users WHERE email = $1 - SQL + SQL return PG_DB.query_one(request, user.email, as: Array(String)) end diff --git a/src/invidious/database/videos.cr b/src/invidious/database/videos.cr index 695f5b335..40bafaf1d 100644 --- a/src/invidious/database/videos.cr +++ b/src/invidious/database/videos.cr @@ -8,7 +8,7 @@ module Invidious::Database::Videos INSERT INTO videos VALUES ($1, $2, $3) ON CONFLICT (id) DO NOTHING - SQL + SQL PG_DB.exec(request, video.id, video.info.to_json, video.updated) end @@ -17,7 +17,7 @@ module Invidious::Database::Videos request = <<-SQL DELETE FROM videos * WHERE id = $1 - SQL + SQL PG_DB.exec(request, id) end @@ -26,7 +26,7 @@ module Invidious::Database::Videos request = <<-SQL DELETE FROM videos * WHERE updated < (now() - interval '6 hours') - SQL + SQL PG_DB.exec(request) end @@ -36,7 +36,7 @@ module Invidious::Database::Videos UPDATE videos SET (id, info, updated) = ($1, $2, $3) WHERE id = $1 - SQL + SQL PG_DB.exec(request, video.id, video.info.to_json, video.updated) end @@ -45,7 +45,7 @@ module Invidious::Database::Videos request = <<-SQL SELECT * FROM videos WHERE id = $1 - SQL + SQL return PG_DB.query_one?(request, id, as: Video) end diff --git a/src/invidious/frontend/comments_reddit.cr b/src/invidious/frontend/comments_reddit.cr index d46e93e7f..08ce2f344 100644 --- a/src/invidious/frontend/comments_reddit.cr +++ b/src/invidious/frontend/comments_reddit.cr @@ -16,33 +16,33 @@ module Invidious::Frontend::Comments if child.depth > 0 html << <<-END_HTML -
- [ − ] - #{child.author} - #{translate_count(locale, "comments_points_count", child.score, NumberFormatting::Separator)} - #{translate(locale, "`x` ago", recode_date(child.created_utc, locale))} - #{translate(locale, "permalink")} -
-+ [ − ] + #{child.author} + #{translate_count(locale, "comments_points_count", child.score, NumberFormatting::Separator)} + #{translate(locale, "`x` ago", recode_date(child.created_utc, locale))} + #{translate(locale, "permalink")} +
+- - #{author_name} - - #{sponsor_icon} -
#{child["contentHtml"]}
- END_HTML ++ + #{author_name} + + #{sponsor_icon} +
#{child["contentHtml"]}
+ END_HTML if child["attachment"]? attachment = child["attachment"] @@ -87,25 +87,25 @@ module Invidious::Frontend::Comments attachment = attachment["imageThumbnails"][1] html << <<-END_HTML -#{attachment["error"]}
-#{attachment["error"]}
+- #{translate(locale, "`x` ago", recode_date(Time.unix(child["published"].as_i64), locale))} #{child["isEdited"] == true ? translate(locale, "(edited)") : ""} - | - END_HTML +
+ #{translate(locale, "`x` ago", recode_date(Time.unix(child["published"].as_i64), locale))} #{child["isEdited"] == true ? translate(locale, "(edited)") : ""} + | + END_HTML if comments["videoId"]? html << <<-END_HTML [YT] | - END_HTML + END_HTML elsif comments["authorId"]? html << <<-END_HTML [YT] | - END_HTML + END_HTML end html << <<-END_HTML #{number_with_separator(child["likeCount"])} - END_HTML + END_HTML if child["creatorHeart"]? if !thin_mode @@ -180,28 +180,28 @@ module Invidious::Frontend::Comments - END_HTML + END_HTML end html << <<-END_HTML -
- #{replies_html} + + #{replies_html} +- #{translate(locale, "Load more")} -
+#{issue_template}