Check deleted channels

This commit is contained in:
Omar Roth 2019-02-18 15:44:15 -06:00
parent f85472c0ce
commit 1ceb827a82
1 changed files with 2 additions and 2 deletions

View File

@ -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 WHERE deleted = false ORDER BY updated") do |rs|
db.query("SELECT id FROM channels ORDER BY updated") do |rs|
rs.each do
id = rs.read(String)
@ -71,7 +71,7 @@ def refresh_channels(db, logger, max_threads = 1, full_refresh = false)
client = make_client(YT_URL)
channel = fetch_channel(id, client, db, full_refresh)
db.exec("UPDATE channels SET updated = $1, author = $2 WHERE id = $3", Time.now, channel.author, id)
db.exec("UPDATE channels SET updated = $1, author = $2, deleted = false 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)