summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorOmar Roth <omarroth@protonmail.com>2019-05-27 12:51:18 -0500
committerOmar Roth <omarroth@protonmail.com>2019-05-27 12:51:18 -0500
commitc07ad0941c07708ac9d50cbbd463905ca7db360b (patch)
treee609cc031a6aec3a763bf87daab5e6abe5f8dae2 /src
parent2f02b38b628ac394a497548c98ae3b6645b99e85 (diff)
downloadinvidious-c07ad0941c07708ac9d50cbbd463905ca7db360b.tar.gz
invidious-c07ad0941c07708ac9d50cbbd463905ca7db360b.tar.bz2
invidious-c07ad0941c07708ac9d50cbbd463905ca7db360b.zip
Fix typo in refresh_feeds
Diffstat (limited to 'src')
-rw-r--r--src/invidious/helpers/jobs.cr42
1 files changed, 22 insertions, 20 deletions
diff --git a/src/invidious/helpers/jobs.cr b/src/invidious/helpers/jobs.cr
index f0be6e9d..d725a023 100644
--- a/src/invidious/helpers/jobs.cr
+++ b/src/invidious/helpers/jobs.cr
@@ -47,34 +47,36 @@ def refresh_feeds(db, logger, max_threads = 1, use_feed_events = false)
# Spawn thread to handle feed events
if use_feed_events
- queue = Deque(String).new(30)
-
spawn do
- loop do
- if event = queue.shift?
- feed = JSON.parse(event)
- email = feed["email"].as_s
- action = feed["action"].as_s
+ queue = Deque(String).new(30)
- 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
+
+ view_name = "subscriptions_#{sha256(email)}"
+
+ case action
+ when "refresh"
+ db.exec("REFRESH MATERIALIZED VIEW #{view_name}")
+ end
- case action
- when "refresh"
- db.exec("REFRESH MATERIALIZED VIEW #{view_name}")
+ # Delete any future events that we just processed
+ queue.delete(event)
+ else
+ sleep 1.second
end
- # Delete any future events that we just processed
- queue.delete(event)
- else
- sleep 1.second
+ Fiber.yield
end
-
- Fiber.yield
end
- end
- PG.connect_listen(PG_URL, "feeds") do |event|
- queue << event.payload
+ PG.connect_listen(PG_URL, "feeds") do |event|
+ queue << event.payload
+ end
end
end