Fix watch filtering from subscription feed when watch history is empty
This commit is contained in:
parent
9b202adebd
commit
03f94db5e2
|
@ -1948,8 +1948,13 @@ get "/feed/subscriptions" do |env|
|
||||||
# Show latest video from a channel that a user hasn't watched
|
# 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"
|
# "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 \
|
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)
|
ORDER BY ucid, published #{sort}", as: ChannelVideo)
|
||||||
else
|
else
|
||||||
# Show latest video from each channel
|
# Show latest video from each channel
|
||||||
|
@ -1963,8 +1968,13 @@ get "/feed/subscriptions" do |env|
|
||||||
if preferences.unseen_only
|
if preferences.unseen_only
|
||||||
# Only show unwatched
|
# 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 \
|
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)
|
ORDER BY published #{sort} LIMIT $1 OFFSET $2", limit, offset, as: ChannelVideo)
|
||||||
else
|
else
|
||||||
# Sort subscriptions as normal
|
# Sort subscriptions as normal
|
||||||
|
|
Loading…
Reference in a new issue