mirror of https://github.com/iv-org/invidious.git
Debug the DB methods for compilations
This commit is contained in:
parent
60a184eda3
commit
ea878e22a1
|
@ -217,6 +217,26 @@ module Invidious::Database::CompilationVideos
|
|||
return PG_DB.query_all(request, compid, index, limit, offset, as: CompilationVideo)
|
||||
end
|
||||
|
||||
def select_id_from_order_index(order_index : Int32)
|
||||
request = <<-SQL
|
||||
SELECT id FROM compilation_videos
|
||||
WHERE order_index = $1
|
||||
LIMIT 1
|
||||
SQL
|
||||
|
||||
return PG_DB.query_one?(request, order_index, as: String)
|
||||
end
|
||||
|
||||
def select_index_from_order_index(order_index : Int32)
|
||||
request = <<-SQL
|
||||
SELECT index FROM compilation_videos
|
||||
WHERE order_index = $1
|
||||
LIMIT 1
|
||||
SQL
|
||||
|
||||
return PG_DB.query_one?(request, order_index, as: VideoIndex)
|
||||
end
|
||||
|
||||
def select_index(compid : String, vid : String) : Int64?
|
||||
request = <<-SQL
|
||||
SELECT index FROM compilation_videos
|
||||
|
@ -253,10 +273,23 @@ module Invidious::Database::CompilationVideos
|
|||
# Update
|
||||
# -------------------
|
||||
|
||||
def update_start_timestamp(compid : String, index : VideoIndex, starting_timestamp_seconds : Int64)
|
||||
def update_start_timestamp(id : String, starting_timestamp_seconds : Int32)
|
||||
request = <<-SQL
|
||||
UPDATE compilation_videos
|
||||
SET starting_timestamp_seconds = starting_timestamp_seconds
|
||||
WHERE id = $2
|
||||
WHERE id = $1
|
||||
SQL
|
||||
|
||||
PG_DB.exec(request, id)
|
||||
end
|
||||
|
||||
def update_end_timestamp(id : String, ending_timestamp_seconds : Int64)
|
||||
request = <<-SQL
|
||||
UPDATE compilation_videos
|
||||
SET ending_timestamp_seconds = ending_timestamp_seconds
|
||||
WHERE id = $1
|
||||
SQL
|
||||
|
||||
PG_DB.exec(request, id)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -225,32 +225,38 @@ module Invidious::Routes::Compilations
|
|||
updated = compilation.updated
|
||||
end
|
||||
|
||||
{1...Invidious::Database::Compilations.count_owned_by(user.email)} each do |index|
|
||||
start_timestamp = env.params.json["_start_timestamp"]?.try &.as(String).byte_slice(0, 150) || compilation.title
|
||||
#{1...Invidious::Database::Compilations.count_owned_by(user.email)}.each do |index|
|
||||
# start_timestamp = env.params.json["_start_timestamp"]?.try &.as(String).byte_slice(0, 150) || compilation.title
|
||||
|
||||
(1..Invidious::Database::Compilations.count_owned_by(user.email)).each do |index| {
|
||||
compilation_video = Invidious::Database::CompilationVideos.select(order_index: index)
|
||||
start_timestamp = env.params.json[index+"_start_timestamp"]?.try &.as(String).byte_slice(0, 8)
|
||||
if !start_timestamp.empty?
|
||||
(0..Invidious::Database::Compilations.count_owned_by(user.email)).each do |index|
|
||||
compilation_video_id = Invidious::Database::CompilationVideos.select_id_from_order_index(order_index: index)
|
||||
#compilation_video_index = Invidious::Database::CompilationVideos.select_index_from_order_index(order_index: index)
|
||||
compilation_video = Invidious::Database::CompilationVideos.select(compid, compilation.index, 0, 1)
|
||||
#numerical_string = index.to
|
||||
json_timestamp_query = index.to_s + "_start_timestamp"
|
||||
start_timestamp = env.params.json[json_timestamp_query]?.try &.as(String).byte_slice(0, 8)
|
||||
if !start_timestamp.nil? && !compilation_video_id.nil?
|
||||
start_timestamp_seconds = decode_length_seconds(start_timestamp)
|
||||
if !start_timestamp_seconds.empty
|
||||
if start_timestamp_seconds >= 0 && start_timestamp_seconds <= compilation_video
|
||||
Invidious::Database::CompilationVideos.update_start_timestamp(compid, compilation_video.index, start_timestamp_seconds)
|
||||
if !start_timestamp_seconds.nil?
|
||||
if start_timestamp_seconds >= 0 && start_timestamp_seconds <= compilation_video[0].starting_timestamp_seconds
|
||||
Invidious::Database::CompilationVideos.update_start_timestamp(compilation_video_id, start_timestamp_seconds)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end_timestamp = env.params.json[index+"_end_timestamp"]?.try &.as(String).byte_slice(0, 8)
|
||||
if !end_timestamp.empty?
|
||||
json_timestamp_query = index.to_s + "_end_timestamp"
|
||||
end_timestamp = env.params.json[json_timestamp_query]?.try &.as(String).byte_slice(0, 8)
|
||||
if !end_timestamp.nil? && !compilation_video_id.nil?
|
||||
end_timestamp_seconds = decode_length_seconds(end_timestamp)
|
||||
if !end_timestamp_seconds.empty
|
||||
if end_timestamp_seconds >= 0 && end_timestamp_seconds <= compilation_video
|
||||
Invidious::Database::CompilationVideos.update_end_timestamp(compid, compilation_video.index, end_timestamp_seconds)
|
||||
if !end_timestamp_seconds.nil?
|
||||
if end_timestamp_seconds >= 0 && end_timestamp_seconds <= compilation_video[0].ending_timestamp_seconds
|
||||
Invidious::Database::CompilationVideos.update_end_timestamp(compilation_video_id, end_timestamp_seconds)
|
||||
end
|
||||
end
|
||||
end
|
||||
}
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def self.add_compilation_items_page(env)
|
||||
|
|
|
@ -53,7 +53,7 @@
|
|||
<p><%= translate_count(locale, "generic_channels_count", item.channel_count, NumberFormatting::Separator) %></p>
|
||||
<%- end -%>
|
||||
</div>
|
||||
<% when SearchPlaylist, InvidiousPlaylist %>
|
||||
<% when SearchPlaylist, InvidiousPlaylist, InvidiousCompilation %>
|
||||
<%-
|
||||
if item.id.starts_with? "RD"
|
||||
link_url = "/mix?list=#{item.id}&continuation=#{URI.parse(item.thumbnail || "/vi/-----------").request_target.split("/")[2]}"
|
||||
|
@ -87,20 +87,6 @@
|
|||
</p>
|
||||
</a></div>
|
||||
</div>
|
||||
<% when InvidiousCompilation %>
|
||||
<% link_url = "/compilation?list=#{item.id}" %>
|
||||
<a style="width:100%" href="<%= link_url %>">
|
||||
<% if !env.get("preferences").as(Preferences).thin_mode %>
|
||||
<div class="thumbnail">
|
||||
<img loading="lazy" tabindex="-1" class="thumbnail" src="<%= URI.parse(item.thumbnail || "/").request_target %>" alt="" />
|
||||
<p class="length"><%= translate_count(locale, "generic_videos_count", item.video_count, NumberFormatting::Separator) %></p>
|
||||
</div>
|
||||
<% end %>
|
||||
<p dir="auto"><%= HTML.escape(item.title) %></p>
|
||||
</a>
|
||||
<a href="/channel/<%= item.ucid %>">
|
||||
<p dir="auto"><b><%= HTML.escape(item.author) %><% if !item.is_a?(InvidiousCompilation) && !item.is_a?(InvidiousPlaylist) && !item.author_verified.nil? && item.author_verified %> <i class="icon ion ion-md-checkmark-circle"></i><% end %></b></p>
|
||||
</a>
|
||||
<% when Category %>
|
||||
<% else %>
|
||||
<%-
|
||||
|
|
Loading…
Reference in New Issue