mirror of
https://gitea.invidious.io/iv-org/invidious
synced 2024-12-22 14:35:46 +01:00
Add 'deleted' to channel info
This commit is contained in:
parent
7a9ef0d664
commit
30e6d29106
4
config/migrate-scripts/migrate-db-e1aa1ce.sh
Normal file
4
config/migrate-scripts/migrate-db-e1aa1ce.sh
Normal file
@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
|
||||
psql invidious -c "ALTER TABLE channels ADD COLUMN deleted bool;"
|
||||
psql invidious -c "UPDATE channels SET deleted = false;"
|
@ -7,6 +7,7 @@ CREATE TABLE public.channels
|
||||
id text NOT NULL,
|
||||
author text,
|
||||
updated timestamp with time zone,
|
||||
deleted boolean,
|
||||
CONSTRAINT channels_id_key UNIQUE (id)
|
||||
);
|
||||
|
||||
|
@ -3,6 +3,7 @@ class InvidiousChannel
|
||||
id: String,
|
||||
author: String,
|
||||
updated: Time,
|
||||
deleted: Bool,
|
||||
})
|
||||
end
|
||||
|
||||
@ -187,7 +188,7 @@ def fetch_channel(ucid, client, db, pull_all_videos = true, locale = nil)
|
||||
db.exec("DELETE FROM channel_videos * WHERE NOT id = ANY ('{#{ids.map { |id| %("#{id}") }.join(",")}}') AND ucid = $1", ucid)
|
||||
end
|
||||
|
||||
channel = InvidiousChannel.new(ucid, author, Time.now)
|
||||
channel = InvidiousChannel.new(ucid, author, Time.now, false)
|
||||
|
||||
return channel
|
||||
end
|
||||
|
@ -55,7 +55,7 @@ def refresh_channels(db, logger, max_threads = 1, full_refresh = false)
|
||||
active_channel = Channel(Bool).new
|
||||
|
||||
loop do
|
||||
db.query("SELECT id FROM channels ORDER BY updated") do |rs|
|
||||
db.query("SELECT id FROM channels WHERE deleted = false ORDER BY updated") do |rs|
|
||||
rs.each do
|
||||
id = rs.read(String)
|
||||
|
||||
@ -73,6 +73,9 @@ def refresh_channels(db, logger, max_threads = 1, full_refresh = false)
|
||||
|
||||
db.exec("UPDATE channels SET updated = $1, author = $2 WHERE id = $3", Time.now, channel.author, id)
|
||||
rescue ex
|
||||
if ex.message == "Deleted or invalid channel"
|
||||
db.exec("UPDATE channels SET deleted = true WHERE id = $1", id)
|
||||
end
|
||||
logger.write("#{id} : #{ex.message}\n")
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user