mirror of https://github.com/iv-org/invidious.git
Update sorting for subscriptions
This commit is contained in:
parent
b9c7501012
commit
ce528c9783
|
@ -1909,12 +1909,6 @@ get "/feed/subscriptions" do |env|
|
||||||
offset = (page - 1) * max_results
|
offset = (page - 1) * max_results
|
||||||
end
|
end
|
||||||
|
|
||||||
if preferences.sort == "published - reverse"
|
|
||||||
sort = ""
|
|
||||||
else
|
|
||||||
sort = "DESC"
|
|
||||||
end
|
|
||||||
|
|
||||||
notifications = PG_DB.query_one("SELECT notifications FROM users WHERE email = $1", user.email,
|
notifications = PG_DB.query_one("SELECT notifications FROM users WHERE email = $1", user.email,
|
||||||
as: Array(String))
|
as: Array(String))
|
||||||
view_name = "subscriptions_#{sha256(user.email)[0..7]}"
|
view_name = "subscriptions_#{sha256(user.email)[0..7]}"
|
||||||
|
@ -1925,7 +1919,7 @@ get "/feed/subscriptions" do |env|
|
||||||
args = arg_array(notifications)
|
args = arg_array(notifications)
|
||||||
|
|
||||||
notifications = PG_DB.query_all("SELECT * FROM channel_videos WHERE id IN (#{args})
|
notifications = PG_DB.query_all("SELECT * FROM channel_videos WHERE id IN (#{args})
|
||||||
ORDER BY published #{sort}", notifications, as: ChannelVideo)
|
ORDER BY published DESC", notifications, as: ChannelVideo)
|
||||||
videos = [] of ChannelVideo
|
videos = [] of ChannelVideo
|
||||||
|
|
||||||
notifications.sort_by! { |video| video.published }.reverse!
|
notifications.sort_by! { |video| video.published }.reverse!
|
||||||
|
@ -1953,7 +1947,7 @@ get "/feed/subscriptions" do |env|
|
||||||
end
|
end
|
||||||
videos = PG_DB.query_all("SELECT DISTINCT ON (ucid) * FROM #{view_name} WHERE \
|
videos = PG_DB.query_all("SELECT DISTINCT ON (ucid) * FROM #{view_name} WHERE \
|
||||||
NOT id = ANY (#{values}) \
|
NOT id = ANY (#{values}) \
|
||||||
ORDER BY ucid, published #{sort}", as: ChannelVideo)
|
ORDER BY ucid, published DESC", as: ChannelVideo)
|
||||||
else
|
else
|
||||||
# Show latest video from each channel
|
# Show latest video from each channel
|
||||||
|
|
||||||
|
@ -1973,12 +1967,12 @@ get "/feed/subscriptions" do |env|
|
||||||
end
|
end
|
||||||
videos = PG_DB.query_all("SELECT * FROM #{view_name} WHERE \
|
videos = PG_DB.query_all("SELECT * FROM #{view_name} WHERE \
|
||||||
NOT id = ANY (#{values}) \
|
NOT id = ANY (#{values}) \
|
||||||
ORDER BY published #{sort} LIMIT $1 OFFSET $2", limit, offset, as: ChannelVideo)
|
ORDER BY published DESC LIMIT $1 OFFSET $2", limit, offset, as: ChannelVideo)
|
||||||
else
|
else
|
||||||
# Sort subscriptions as normal
|
# Sort subscriptions as normal
|
||||||
|
|
||||||
videos = PG_DB.query_all("SELECT * FROM #{view_name} \
|
videos = PG_DB.query_all("SELECT * FROM #{view_name} \
|
||||||
ORDER BY published #{sort} LIMIT $1 OFFSET $2", limit, offset, as: ChannelVideo)
|
ORDER BY published DESC LIMIT $1 OFFSET $2", limit, offset, as: ChannelVideo)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -2197,12 +2191,6 @@ get "/feed/private" do |env|
|
||||||
sort = env.params.query["sort"]?
|
sort = env.params.query["sort"]?
|
||||||
sort ||= "published"
|
sort ||= "published"
|
||||||
|
|
||||||
if sort == "published - reverse"
|
|
||||||
desc = ""
|
|
||||||
else
|
|
||||||
desc = "DESC"
|
|
||||||
end
|
|
||||||
|
|
||||||
view_name = "subscriptions_#{sha256(user.email)[0..7]}"
|
view_name = "subscriptions_#{sha256(user.email)[0..7]}"
|
||||||
|
|
||||||
if latest_only
|
if latest_only
|
||||||
|
@ -2212,7 +2200,7 @@ get "/feed/private" do |env|
|
||||||
videos.sort_by! { |video| video.published }.reverse!
|
videos.sort_by! { |video| video.published }.reverse!
|
||||||
else
|
else
|
||||||
videos = PG_DB.query_all("SELECT * FROM #{view_name} \
|
videos = PG_DB.query_all("SELECT * FROM #{view_name} \
|
||||||
ORDER BY published #{desc} LIMIT $1 OFFSET $2", limit, offset, as: ChannelVideo)
|
ORDER BY published DESC LIMIT $1 OFFSET $2", limit, offset, as: ChannelVideo)
|
||||||
end
|
end
|
||||||
|
|
||||||
case sort
|
case sort
|
||||||
|
|
Loading…
Reference in New Issue