mirror of
https://github.com/iv-org/invidious.git
synced 2025-08-18 10:38:32 +00:00
Add select_all for channels and use in refresh job
This commit is contained in:
parent
8b0ed8b110
commit
7e25ad5e4e
@ -76,6 +76,14 @@ module Invidious::Database::Channels
|
||||
|
||||
return PG_DB.query_all(request, as: InvidiousChannel)
|
||||
end
|
||||
|
||||
def select_all : Array(InvidiousChannel)
|
||||
request = <<-SQL
|
||||
SELECT * FROM channels
|
||||
SQL
|
||||
|
||||
return PG_DB.query_all(rqeuest, as: InvidiousChannel)
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
|
@ -13,10 +13,8 @@ class Invidious::Jobs::RefreshChannelsJob < Invidious::Jobs::BaseJob
|
||||
|
||||
loop do
|
||||
LOGGER.debug("RefreshChannelsJob: Refreshing all channels")
|
||||
PG_DB.query("SELECT id FROM channels ORDER BY updated") do |rs|
|
||||
rs.each do
|
||||
id = rs.read(String)
|
||||
|
||||
Invidious::Database::Channels.select_all.each do |channel|
|
||||
id = channel.id
|
||||
if active_fibers >= lim_fibers
|
||||
LOGGER.trace("RefreshChannelsJob: Fiber limit reached, waiting...")
|
||||
if active_channel.receive
|
||||
@ -56,7 +54,6 @@ class Invidious::Jobs::RefreshChannelsJob < Invidious::Jobs::BaseJob
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# TODO: make this configurable
|
||||
LOGGER.debug("RefreshChannelsJob: Done, sleeping for thirty minutes")
|
||||
|
Loading…
Reference in New Issue
Block a user