mirror of
https://gitea.invidious.io/iv-org/invidious.git
synced 2024-08-15 00:53:41 +00:00
Speed up filtering watched videos from feed
This commit is contained in:
parent
6cea83991c
commit
421ad21b40
1 changed files with 4 additions and 16 deletions
|
@ -1819,15 +1819,9 @@ get "/feed/subscriptions" do |env|
|
||||||
else
|
else
|
||||||
if preferences.latest_only
|
if preferences.latest_only
|
||||||
if preferences.unseen_only
|
if preferences.unseen_only
|
||||||
if user.watched.empty?
|
|
||||||
watched = "'{}'"
|
|
||||||
else
|
|
||||||
watched = arg_array(user.watched)
|
|
||||||
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 \
|
||||||
id NOT IN (#{watched}) ORDER BY ucid, published #{sort}",
|
NOT id = ANY (VALUES #{user.watched.map { |id| %(('#{id}')) }.join(",")}) \
|
||||||
user.watched, as: ChannelVideo)
|
ORDER BY ucid, published #{sort}", as: ChannelVideo)
|
||||||
else
|
else
|
||||||
videos = PG_DB.query_all("SELECT DISTINCT ON (ucid) * FROM #{view_name} \
|
videos = PG_DB.query_all("SELECT DISTINCT ON (ucid) * FROM #{view_name} \
|
||||||
ORDER BY ucid, published #{sort}", as: ChannelVideo)
|
ORDER BY ucid, published #{sort}", as: ChannelVideo)
|
||||||
|
@ -1836,15 +1830,9 @@ get "/feed/subscriptions" do |env|
|
||||||
videos.sort_by! { |video| video.published }.reverse!
|
videos.sort_by! { |video| video.published }.reverse!
|
||||||
else
|
else
|
||||||
if preferences.unseen_only
|
if preferences.unseen_only
|
||||||
if user.watched.empty?
|
|
||||||
watched = "'{}'"
|
|
||||||
else
|
|
||||||
watched = arg_array(user.watched, 3)
|
|
||||||
end
|
|
||||||
|
|
||||||
videos = PG_DB.query_all("SELECT * FROM #{view_name} WHERE \
|
videos = PG_DB.query_all("SELECT * FROM #{view_name} WHERE \
|
||||||
id NOT IN (#{watched}) ORDER BY published #{sort} LIMIT $1 OFFSET $2",
|
NOT id = ANY (VALUES #{user.watched.map { |id| %(('#{id}')) }.join(",")}) \
|
||||||
[limit, offset] + user.watched, as: ChannelVideo)
|
ORDER BY published #{sort} LIMIT $1 OFFSET $2", limit, offset, as: ChannelVideo)
|
||||||
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 #{sort} LIMIT $1 OFFSET $2", limit, offset, as: ChannelVideo)
|
||||||
|
|
Loading…
Reference in a new issue