Don't overwrite published date for channel_videos

pull/508/head
Omar Roth 6 years ago
parent fb7068d415
commit 14620c32aa

@ -102,8 +102,9 @@ def fetch_channel(ucid, db, pull_all_videos = true, locale = nil)
auto_generated = true auto_generated = true
end end
if !pull_all_videos page = 1
url = produce_channel_videos_url(ucid, 1, auto_generated: auto_generated)
url = produce_channel_videos_url(ucid, page, auto_generated: auto_generated)
response = client.get(url) response = client.get(url)
json = JSON.parse(response.body) 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 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( video = ChannelVideo.new(
id: video_id, id: video_id,
title: title, 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, \ updated = $4, ucid = $5, author = $6, length_seconds = $7, \
live_now = $8", video_array) live_now = $8", video_array)
end end
else
page = 1 if pull_all_videos
page += 1
ids = [] of String ids = [] of String
loop do loop do
@ -186,6 +182,8 @@ def fetch_channel(ucid, db, pull_all_videos = true, locale = nil)
break break
end end
nodeset = nodeset.not_nil!
if auto_generated if auto_generated
videos = extract_videos(nodeset) videos = extract_videos(nodeset)
else else
@ -216,16 +214,14 @@ 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, # We don't update 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, updated = $4, \
updated = $4, ucid = $5, author = $6, length_seconds = $7, \ ucid = $5, author = $6, length_seconds = $7, live_now = $8", video_array)
live_now = $8", video_array)
end end
end end
if count < 30 if count < 25
break break
end end

Loading…
Cancel
Save