diff options
| author | Omar Roth <omarroth@hotmail.com> | 2019-03-02 20:13:41 -0600 |
|---|---|---|
| committer | Omar Roth <omarroth@hotmail.com> | 2019-03-02 20:13:41 -0600 |
| commit | 03f94db5e2541cb9474d90737d9c0ae95609835a (patch) | |
| tree | 0f43e2363d183bca4e8644c5d5fc987730cff03c /src | |
| parent | 9b202adebd55292f523ab4db918f99fb52eb5fd9 (diff) | |
| download | invidious-03f94db5e2541cb9474d90737d9c0ae95609835a.tar.gz invidious-03f94db5e2541cb9474d90737d9c0ae95609835a.tar.bz2 invidious-03f94db5e2541cb9474d90737d9c0ae95609835a.zip | |
Fix watch filtering from subscription feed when watch history is empty
Diffstat (limited to 'src')
| -rw-r--r-- | src/invidious.cr | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/invidious.cr b/src/invidious.cr index 20bb703b..cbcba12e 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -1948,8 +1948,13 @@ get "/feed/subscriptions" do |env| # Show latest video from a channel that a user hasn't watched # "unseen_only" isn't really correct here, more accurate would be "unwatched_only" + if user.watched.empty? + values = "'{}'" + else + values = "VALUES #{user.watched.map { |id| %(('#{id}')) }.join(",")}" + end videos = PG_DB.query_all("SELECT DISTINCT ON (ucid) * FROM #{view_name} WHERE \ - NOT id = ANY (VALUES #{user.watched.map { |id| %(('#{id}')) }.join(",")}) \ + NOT id = ANY (#{values}) \ ORDER BY ucid, published #{sort}", as: ChannelVideo) else # Show latest video from each channel @@ -1963,8 +1968,13 @@ get "/feed/subscriptions" do |env| if preferences.unseen_only # Only show unwatched + if user.watched.empty? + values = "'{}'" + else + values = "VALUES #{user.watched.map { |id| %(('#{id}')) }.join(",")}" + end videos = PG_DB.query_all("SELECT * FROM #{view_name} WHERE \ - NOT id = ANY (VALUES #{user.watched.map { |id| %(('#{id}')) }.join(",")}) \ + NOT id = ANY (#{values}) \ ORDER BY published #{sort} LIMIT $1 OFFSET $2", limit, offset, as: ChannelVideo) else # Sort subscriptions as normal |
