summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorOmar Roth <omarroth@hotmail.com>2019-02-21 13:26:36 -0600
committerOmar Roth <omarroth@hotmail.com>2019-02-21 14:01:12 -0600
commit40073e7089efb532417ac072297a8fae45706ffc (patch)
treeebac3b3de4d05ad48cfba570670c34a354687f8c /src
parent0e141f21e80d236e7f5c29ed105244d3bb4052d9 (diff)
downloadinvidious-40073e7089efb532417ac072297a8fae45706ffc.tar.gz
invidious-40073e7089efb532417ac072297a8fae45706ffc.tar.bz2
invidious-40073e7089efb532417ac072297a8fae45706ffc.zip
Fix sorting options for /feed/private
Diffstat (limited to 'src')
-rw-r--r--src/invidious.cr20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/invidious.cr b/src/invidious.cr
index 19b924c2..e7fa4c90 100644
--- a/src/invidious.cr
+++ b/src/invidious.cr
@@ -2053,26 +2053,30 @@ get "/feed/private" do |env|
latest_only ||= 0
latest_only = latest_only == 1
- if user.preferences.sort == "published - reverse"
- sort = ""
+ sort = env.params.query["sort"]?
+ sort ||= "published"
+
+ if sort == "published - reverse"
+ desc = ""
else
- sort = "DESC"
+ desc = "DESC"
end
view_name = "subscriptions_#{sha256(user.email)[0..7]}"
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!
else
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
- sort = env.params.query["sort"]?
- sort ||= "published"
-
case sort
+ when "reverse_published"
+ videos.sort_by! { |video| video.published }
when "alphabetically"
videos.sort_by! { |video| video.title }
when "reverse_alphabetically"