Don't overwrite published date for channel_videos

This commit is contained in:
Omar Roth 2019-04-20 10:18:54 -05:00
parent fb7068d415
commit 14620c32aa

View File

@ -102,8 +102,9 @@ def fetch_channel(ucid, db, pull_all_videos = true, locale = nil)
auto_generated = true
end
if !pull_all_videos
url = produce_channel_videos_url(ucid, 1, auto_generated: auto_generated)
page = 1
url = produce_channel_videos_url(ucid, page, auto_generated: auto_generated)
response = client.get(url)
json = JSON.parse(response.body)
@ -138,13 +139,6 @@ def fetch_channel(ucid, db, pull_all_videos = true, locale = nil)
premiere_timestamp = channel_video.try &.premiere_timestamp
# Deliver notifications to `/api/v1/auth/notifications`
# payload = {
# "key" => video_id,
# "topic" => ucid,
# }.to_json
# PG_DB.exec("NOTIFY notifications, E'#{payload}'")
video = ChannelVideo.new(
id: video_id,
title: title,
@ -170,8 +164,10 @@ def fetch_channel(ucid, db, pull_all_videos = true, locale = nil)
updated = $4, ucid = $5, author = $6, length_seconds = $7, \
live_now = $8", video_array)
end
else
page = 1
if pull_all_videos
page += 1
ids = [] of String
loop do
@ -186,6 +182,8 @@ def fetch_channel(ucid, db, pull_all_videos = true, locale = nil)
break
end
nodeset = nodeset.not_nil!
if auto_generated
videos = extract_videos(nodeset)
else
@ -216,16 +214,14 @@ def fetch_channel(ucid, db, pull_all_videos = true, locale = nil)
video_array = video.to_a
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
# We don't update the 'premire_timestamp' here because channel pages don't include them
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)
ON CONFLICT (id) DO UPDATE SET title = $2, updated = $4, \
ucid = $5, author = $6, length_seconds = $7, live_now = $8", video_array)
end
end
if count < 30
if count < 25
break
end