mirror of
https://github.com/iv-org/invidious.git
synced 2024-12-23 00:29:53 +05:30
Don't change id for video conflict
This commit is contained in:
parent
385d6301a3
commit
60360ee2ae
@ -207,14 +207,14 @@ def get_video(id, client, db, refresh = true)
|
|||||||
video = db.query_one("SELECT * FROM videos WHERE id = $1", id, as: Video)
|
video = db.query_one("SELECT * FROM videos WHERE id = $1", id, as: Video)
|
||||||
|
|
||||||
# If record was last updated over an hour ago, refresh (expire param in response lasts for 6 hours)
|
# If record was last updated over an hour ago, refresh (expire param in response lasts for 6 hours)
|
||||||
if refresh && Time.now - video.updated > 1.hours
|
if refresh && Time.now - video.updated > 1.second
|
||||||
begin
|
begin
|
||||||
video = fetch_video(id, client)
|
video = fetch_video(id, client)
|
||||||
video_array = video.to_a[1..-1]
|
video_array = video.to_a
|
||||||
args = arg_array(video_array)
|
args = arg_array(video_array[1..-1], 2)
|
||||||
|
|
||||||
db.exec("UPDATE videos SET (id,info,updated,title,views,likes,dislikes,wilson_score,published,description,language)\
|
db.exec("UPDATE videos SET (info,updated,title,views,likes,dislikes,wilson_score,published,description,language)\
|
||||||
= (#{args}) WHERE id = '#{video.id}'", video_array)
|
= (#{args}) WHERE id = $1", video_array)
|
||||||
rescue ex
|
rescue ex
|
||||||
db.exec("DELETE FROM videos * WHERE id = $1", id)
|
db.exec("DELETE FROM videos * WHERE id = $1", id)
|
||||||
end
|
end
|
||||||
@ -417,9 +417,9 @@ def number_with_separator(number)
|
|||||||
number.to_s.reverse.gsub(/(\d{3})(?=\d)/, "\\1,").reverse
|
number.to_s.reverse.gsub(/(\d{3})(?=\d)/, "\\1,").reverse
|
||||||
end
|
end
|
||||||
|
|
||||||
def arg_array(array)
|
def arg_array(array, start = 1)
|
||||||
args = [] of String
|
args = [] of String
|
||||||
(1..array.size).each { |i| args << "($#{i})" }
|
(start..array.size + start - 1).each { |i| args << "($#{i})" }
|
||||||
args = args.join(",")
|
args = args.join(",")
|
||||||
|
|
||||||
return args
|
return args
|
||||||
|
Loading…
Reference in New Issue
Block a user