|
|
@ -10,14 +10,15 @@ end
|
|
|
|
|
|
|
|
|
|
|
|
class ChannelVideo
|
|
|
|
class ChannelVideo
|
|
|
|
add_mapping({
|
|
|
|
add_mapping({
|
|
|
|
id: String,
|
|
|
|
id: String,
|
|
|
|
title: String,
|
|
|
|
title: String,
|
|
|
|
published: Time,
|
|
|
|
published: Time,
|
|
|
|
updated: Time,
|
|
|
|
updated: Time,
|
|
|
|
ucid: String,
|
|
|
|
ucid: String,
|
|
|
|
author: String,
|
|
|
|
author: String,
|
|
|
|
length_seconds: {type: Int32, default: 0},
|
|
|
|
length_seconds: {type: Int32, default: 0},
|
|
|
|
live_now: {type: Bool, default: false},
|
|
|
|
live_now: {type: Bool, default: false},
|
|
|
|
|
|
|
|
premiere_timestamp: {type: Time?, default: nil},
|
|
|
|
})
|
|
|
|
})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
@ -126,7 +127,19 @@ def fetch_channel(ucid, db, pull_all_videos = true, locale = nil)
|
|
|
|
live_now = channel_video.try &.live_now
|
|
|
|
live_now = channel_video.try &.live_now
|
|
|
|
live_now ||= false
|
|
|
|
live_now ||= false
|
|
|
|
|
|
|
|
|
|
|
|
video = ChannelVideo.new(video_id, title, published, Time.now, ucid, author, length_seconds, live_now)
|
|
|
|
premiere_timestamp = channel_video.try &.premiere_timestamp
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
video = ChannelVideo.new(
|
|
|
|
|
|
|
|
video_id,
|
|
|
|
|
|
|
|
title,
|
|
|
|
|
|
|
|
published,
|
|
|
|
|
|
|
|
Time.now,
|
|
|
|
|
|
|
|
ucid,
|
|
|
|
|
|
|
|
author,
|
|
|
|
|
|
|
|
length_seconds,
|
|
|
|
|
|
|
|
live_now,
|
|
|
|
|
|
|
|
premiere_timestamp
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
db.exec("UPDATE users SET notifications = notifications || $1 \
|
|
|
|
db.exec("UPDATE users SET notifications = notifications || $1 \
|
|
|
|
WHERE updated < $2 AND $3 = ANY(subscriptions) AND $1 <> ALL(notifications)", video.id, video.published, ucid)
|
|
|
|
WHERE updated < $2 AND $3 = ANY(subscriptions) AND $1 <> ALL(notifications)", video.id, video.published, ucid)
|
|
|
@ -134,9 +147,12 @@ def fetch_channel(ucid, db, pull_all_videos = true, locale = nil)
|
|
|
|
video_array = video.to_a
|
|
|
|
video_array = video.to_a
|
|
|
|
args = arg_array(video_array)
|
|
|
|
args = arg_array(video_array)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# We don't include the 'premire_timestamp' here because channel pages don't include them,
|
|
|
|
|
|
|
|
# meaning the above timestamp is always null
|
|
|
|
db.exec("INSERT INTO channel_videos VALUES (#{args}) \
|
|
|
|
db.exec("INSERT INTO channel_videos VALUES (#{args}) \
|
|
|
|
ON CONFLICT (id) DO UPDATE SET title = $2, published = $3, \
|
|
|
|
ON CONFLICT (id) DO UPDATE SET title = $2, published = $3, \
|
|
|
|
updated = $4, ucid = $5, author = $6, length_seconds = $7, live_now = $8", video_array)
|
|
|
|
updated = $4, ucid = $5, author = $6, length_seconds = $7, \
|
|
|
|
|
|
|
|
live_now = $8", video_array)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
else
|
|
|
|
else
|
|
|
|
page = 1
|
|
|
|
page = 1
|
|
|
@ -163,7 +179,17 @@ def fetch_channel(ucid, db, pull_all_videos = true, locale = nil)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
count = nodeset.size
|
|
|
|
count = nodeset.size
|
|
|
|
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 = videos.map { |video| ChannelVideo.new(
|
|
|
|
|
|
|
|
video.id,
|
|
|
|
|
|
|
|
video.title,
|
|
|
|
|
|
|
|
video.published,
|
|
|
|
|
|
|
|
Time.now,
|
|
|
|
|
|
|
|
video.ucid,
|
|
|
|
|
|
|
|
video.author,
|
|
|
|
|
|
|
|
video.length_seconds,
|
|
|
|
|
|
|
|
video.live_now,
|
|
|
|
|
|
|
|
video.premiere_timestamp
|
|
|
|
|
|
|
|
) }
|
|
|
|
|
|
|
|
|
|
|
|
videos.each do |video|
|
|
|
|
videos.each do |video|
|
|
|
|
ids << video.id
|
|
|
|
ids << video.id
|
|
|
@ -176,8 +202,12 @@ def fetch_channel(ucid, db, pull_all_videos = true, locale = nil)
|
|
|
|
video_array = video.to_a
|
|
|
|
video_array = video.to_a
|
|
|
|
args = arg_array(video_array)
|
|
|
|
args = arg_array(video_array)
|
|
|
|
|
|
|
|
|
|
|
|
db.exec("INSERT INTO channel_videos VALUES (#{args}) ON CONFLICT (id) DO UPDATE SET title = $2, \
|
|
|
|
# We don't include the 'premire_timestamp' here because channel pages don't include them,
|
|
|
|
published = $3, updated = $4, ucid = $5, author = $6, length_seconds = $7, live_now = $8", video_array)
|
|
|
|
# meaning the above timestamp is always null
|
|
|
|
|
|
|
|
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, \
|
|
|
|
|
|
|
|
live_now = $8", video_array)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|