From c099a5ad2e42616ee96a5da41cf27083606ac692 Mon Sep 17 00:00:00 2001 From: Omar Roth Date: Fri, 15 Feb 2019 17:13:52 -0600 Subject: [PATCH] Speed up manage_subscriptions --- src/invidious.cr | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/invidious.cr b/src/invidious.cr index 285d4394..93f63dfe 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -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