From 6f3f0d92ffae35eaf0b7b3ac6991e3149b70e282 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Sat, 13 Dec 2025 21:32:37 -0800 Subject: [PATCH] fix N+1 queries in parties index --- app/controllers/concerns/party_querying_concern.rb | 4 ++-- app/models/party.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/concerns/party_querying_concern.rb b/app/controllers/concerns/party_querying_concern.rb index d508384..d8ff479 100644 --- a/app/controllers/concerns/party_querying_concern.rb +++ b/app/controllers/concerns/party_querying_concern.rb @@ -9,7 +9,7 @@ module PartyQueryingConcern Party.includes( { raid: :group }, :job, - :user, + { user: { active_crew_membership: :crew } }, :skill0, :skill1, :skill2, @@ -18,7 +18,7 @@ module PartyQueryingConcern :guidebook2, :guidebook3, { characters: :character }, - { weapons: :weapon }, + { weapons: { weapon: :weapon_series } }, { summons: :summon } ) end diff --git a/app/models/party.rb b/app/models/party.rb index 27ae673..0ad7a2a 100644 --- a/app/models/party.rb +++ b/app/models/party.rb @@ -265,7 +265,7 @@ class Party < ApplicationRecord return false unless user Rails.cache.fetch("party_#{id}_favorited_by_#{user.id}", expires_in: 1.hour) do - user.favorite_parties.include?(self) + Favorite.exists?(user_id: user.id, party_id: id) end end