gearheads
/
mastodon
Archived
2
0
Fork 0

Fix inefficient queries in “Follows and followers” as well as several admin pages (#27116)

gh/dev^2
Claire 2023-09-25 15:06:43 +02:00
parent 9cb7fa57f6
commit 58477a6163
1 changed files with 4 additions and 4 deletions

View File

@ -62,13 +62,13 @@ class RelationshipFilter
def relationship_scope(value) def relationship_scope(value)
case value case value
when 'following' when 'following'
account.following.eager_load(:account_stat).reorder(nil) account.following.includes(:account_stat).reorder(nil)
when 'followed_by' when 'followed_by'
account.followers.eager_load(:account_stat).reorder(nil) account.followers.includes(:account_stat).reorder(nil)
when 'mutual' 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' 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 else
raise Mastodon::InvalidParameterError, "Unknown relationship: #{value}" raise Mastodon::InvalidParameterError, "Unknown relationship: #{value}"
end end