Move DB queries related to channels in a separate module

This commit is contained in:
Samantaz Fox
2021-12-02 19:16:41 +01:00
parent d94d4c2045
commit c021b93b5c
9 changed files with 164 additions and 52 deletions

View File

@@ -235,11 +235,12 @@ def create_notification_stream(env, topics, connection_channel)
spawn do
begin
if since
since_unix = Time.unix(since.not_nil!)
topics.try &.each do |topic|
case topic
when .match(/UC[A-Za-z0-9_-]{22}/)
PG_DB.query_all("SELECT * FROM channel_videos WHERE ucid = $1 AND published > $2 ORDER BY published DESC LIMIT 15",
topic, Time.unix(since.not_nil!), as: ChannelVideo).each do |video|
Invidious::Database::ChannelVideos.select_notfications(topic, since_unix).each do |video|
response = JSON.parse(video.to_json(locale))
if fields_text = env.params.query["fields"]?