mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2022-03-16.git
synced 2024-08-15 00:53:18 +00:00
Fix typo in refresh_feeds
This commit is contained in:
parent
2f02b38b62
commit
c07ad0941c
1 changed files with 22 additions and 20 deletions
|
@ -47,34 +47,36 @@ def refresh_feeds(db, logger, max_threads = 1, use_feed_events = false)
|
||||||
|
|
||||||
# Spawn thread to handle feed events
|
# Spawn thread to handle feed events
|
||||||
if use_feed_events
|
if use_feed_events
|
||||||
queue = Deque(String).new(30)
|
|
||||||
|
|
||||||
spawn do
|
spawn do
|
||||||
loop do
|
queue = Deque(String).new(30)
|
||||||
if event = queue.shift?
|
|
||||||
feed = JSON.parse(event)
|
|
||||||
email = feed["email"].as_s
|
|
||||||
action = feed["action"].as_s
|
|
||||||
|
|
||||||
view_name = "subscriptions_#{sha256(email)}"
|
spawn do
|
||||||
|
loop do
|
||||||
|
if event = queue.shift?
|
||||||
|
feed = JSON.parse(event)
|
||||||
|
email = feed["email"].as_s
|
||||||
|
action = feed["action"].as_s
|
||||||
|
|
||||||
case action
|
view_name = "subscriptions_#{sha256(email)}"
|
||||||
when "refresh"
|
|
||||||
db.exec("REFRESH MATERIALIZED VIEW #{view_name}")
|
case action
|
||||||
|
when "refresh"
|
||||||
|
db.exec("REFRESH MATERIALIZED VIEW #{view_name}")
|
||||||
|
end
|
||||||
|
|
||||||
|
# Delete any future events that we just processed
|
||||||
|
queue.delete(event)
|
||||||
|
else
|
||||||
|
sleep 1.second
|
||||||
end
|
end
|
||||||
|
|
||||||
# Delete any future events that we just processed
|
Fiber.yield
|
||||||
queue.delete(event)
|
|
||||||
else
|
|
||||||
sleep 1.second
|
|
||||||
end
|
end
|
||||||
|
|
||||||
Fiber.yield
|
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
PG.connect_listen(PG_URL, "feeds") do |event|
|
PG.connect_listen(PG_URL, "feeds") do |event|
|
||||||
queue << event.payload
|
queue << event.payload
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue