From 1bd7455d81ea7146efb90413c4a89ea21c65310d Mon Sep 17 00:00:00 2001 From: Claire Date: Mon, 25 Sep 2023 15:06:43 +0200 Subject: [PATCH] =?UTF-8?q?Fix=20inefficient=20queries=20in=20=E2=80=9CFol?= =?UTF-8?q?lows=20and=20followers=E2=80=9D=20as=20well=20as=20several=20ad?= =?UTF-8?q?min=20pages=20(#27116)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/relationship_filter.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/models/relationship_filter.rb b/app/models/relationship_filter.rb index 3d75dce05e..955d7d188a 100644 --- a/app/models/relationship_filter.rb +++ b/app/models/relationship_filter.rb @@ -62,13 +62,13 @@ class RelationshipFilter def relationship_scope(value) case value when 'following' - account.following.eager_load(:account_stat).reorder(nil) + account.following.includes(:account_stat).reorder(nil) when 'followed_by' - account.followers.eager_load(:account_stat).reorder(nil) + account.followers.includes(:account_stat).reorder(nil) when 'mutual' - account.followers.eager_load(:account_stat).reorder(nil).merge(Account.where(id: account.following)) + account.followers.includes(:account_stat).reorder(nil).merge(Account.where(id: account.following)) when 'invited' - Account.joins(user: :invite).merge(Invite.where(user: account.user)).eager_load(:account_stat).reorder(nil) + Account.joins(user: :invite).merge(Invite.where(user: account.user)).includes(:account_stat).reorder(nil) else raise Mastodon::InvalidParameterError, "Unknown relationship: #{value}" end