Speed up manage_subscriptions

This commit is contained in:
Omar Roth 2019-02-15 17:13:52 -06:00
parent 9df77707d3
commit c099a5ad2e

View File

@ -1373,12 +1373,7 @@ get "/subscription_manager" do |env|
format = env.params.query["format"]?
format ||= "rss"
subscriptions = [] of InvidiousChannel
user.subscriptions.each do |ucid|
if channel = PG_DB.query_one?("SELECT * FROM channels WHERE id = $1", ucid, as: InvidiousChannel)
subscriptions << channel
end
end
subscriptions = PG_DB.query_all("SELECT * FROM channels WHERE id = ANY('{#{user.subscriptions.join(",")}}')", as: InvidiousChannel)
subscriptions.sort_by! { |channel| channel.author.downcase }
if action_takeout