Fix sorting options for /feed/private
This commit is contained in:
parent
0e141f21e8
commit
40073e7089
|
@ -2053,26 +2053,30 @@ get "/feed/private" do |env|
|
||||||
latest_only ||= 0
|
latest_only ||= 0
|
||||||
latest_only = latest_only == 1
|
latest_only = latest_only == 1
|
||||||
|
|
||||||
if user.preferences.sort == "published - reverse"
|
sort = env.params.query["sort"]?
|
||||||
sort = ""
|
sort ||= "published"
|
||||||
|
|
||||||
|
if sort == "published - reverse"
|
||||||
|
desc = ""
|
||||||
else
|
else
|
||||||
sort = "DESC"
|
desc = "DESC"
|
||||||
end
|
end
|
||||||
|
|
||||||
view_name = "subscriptions_#{sha256(user.email)[0..7]}"
|
view_name = "subscriptions_#{sha256(user.email)[0..7]}"
|
||||||
|
|
||||||
if latest_only
|
if latest_only
|
||||||
videos = PG_DB.query_all("SELECT DISTINCT ON (ucid) * FROM #{view_name} ORDER BY ucid, published #{sort}", as: ChannelVideo)
|
videos = PG_DB.query_all("SELECT DISTINCT ON (ucid) * FROM #{view_name} \
|
||||||
|
ORDER BY ucid, published", as: ChannelVideo)
|
||||||
|
|
||||||
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 #{sort} LIMIT $1 OFFSET $2", limit, offset, as: ChannelVideo)
|
ORDER BY published #{desc} LIMIT $1 OFFSET $2", limit, offset, as: ChannelVideo)
|
||||||
end
|
end
|
||||||
|
|
||||||
sort = env.params.query["sort"]?
|
|
||||||
sort ||= "published"
|
|
||||||
|
|
||||||
case sort
|
case sort
|
||||||
|
when "reverse_published"
|
||||||
|
videos.sort_by! { |video| video.published }
|
||||||
when "alphabetically"
|
when "alphabetically"
|
||||||
videos.sort_by! { |video| video.title }
|
videos.sort_by! { |video| video.title }
|
||||||
when "reverse_alphabetically"
|
when "reverse_alphabetically"
|
||||||
|
|
Loading…
Reference in a new issue