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