|
|
|
@ -17,6 +17,7 @@ class ChannelVideo
|
|
|
|
|
ucid: String,
|
|
|
|
|
author: String,
|
|
|
|
|
length_seconds: {type: Int32, default: 0},
|
|
|
|
|
live_now: {type: Bool, default: false},
|
|
|
|
|
})
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
@ -120,7 +121,10 @@ def fetch_channel(ucid, db, pull_all_videos = true, locale = nil)
|
|
|
|
|
length_seconds = videos.select { |video| video.id == video_id }[0]?.try &.length_seconds
|
|
|
|
|
length_seconds ||= 0
|
|
|
|
|
|
|
|
|
|
video = ChannelVideo.new(video_id, title, published, Time.now, ucid, author, length_seconds)
|
|
|
|
|
live_now = videos.select { |video| video.id == video_id }[0]?.try &.live_now
|
|
|
|
|
live_now ||= false
|
|
|
|
|
|
|
|
|
|
video = ChannelVideo.new(video_id, title, published, Time.now, ucid, author, length_seconds, live_now)
|
|
|
|
|
|
|
|
|
|
db.exec("UPDATE users SET notifications = notifications || $1 \
|
|
|
|
|
WHERE updated < $2 AND $3 = ANY(subscriptions) AND $1 <> ALL(notifications)", video.id, video.published, ucid)
|
|
|
|
@ -130,7 +134,7 @@ def fetch_channel(ucid, db, pull_all_videos = true, locale = nil)
|
|
|
|
|
|
|
|
|
|
db.exec("INSERT INTO channel_videos VALUES (#{args}) \
|
|
|
|
|
ON CONFLICT (id) DO UPDATE SET title = $2, published = $3, \
|
|
|
|
|
updated = $4, ucid = $5, author = $6, length_seconds = $7", video_array)
|
|
|
|
|
updated = $4, ucid = $5, author = $6, length_seconds = $7, live_now = $8", video_array)
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
page = 1
|
|
|
|
@ -157,7 +161,7 @@ def fetch_channel(ucid, db, pull_all_videos = true, locale = nil)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
count = nodeset.size
|
|
|
|
|
videos = videos.map { |video| ChannelVideo.new(video.id, video.title, video.published, Time.now, video.ucid, video.author, video.length_seconds) }
|
|
|
|
|
videos = videos.map { |video| ChannelVideo.new(video.id, video.title, video.published, Time.now, video.ucid, video.author, video.length_seconds, video.live_now) }
|
|
|
|
|
|
|
|
|
|
videos.each do |video|
|
|
|
|
|
ids << video.id
|
|
|
|
@ -171,7 +175,7 @@ def fetch_channel(ucid, db, pull_all_videos = true, locale = nil)
|
|
|
|
|
args = arg_array(video_array)
|
|
|
|
|
|
|
|
|
|
db.exec("INSERT INTO channel_videos VALUES (#{args}) ON CONFLICT (id) DO UPDATE SET title = $2, \
|
|
|
|
|
published = $3, updated = $4, ucid = $5, author = $6, length_seconds = $7", video_array)
|
|
|
|
|
published = $3, updated = $4, ucid = $5, author = $6, length_seconds = $7, live_now = $8", video_array)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|