fix N+1 queries in parties index

This commit is contained in:
Justin Edmund 2025-12-13 21:32:37 -08:00
parent ef7c158736
commit 6f3f0d92ff
2 changed files with 3 additions and 3 deletions

View file

@ -9,7 +9,7 @@ module PartyQueryingConcern
Party.includes( Party.includes(
{ raid: :group }, { raid: :group },
:job, :job,
:user, { user: { active_crew_membership: :crew } },
:skill0, :skill0,
:skill1, :skill1,
:skill2, :skill2,
@ -18,7 +18,7 @@ module PartyQueryingConcern
:guidebook2, :guidebook2,
:guidebook3, :guidebook3,
{ characters: :character }, { characters: :character },
{ weapons: :weapon }, { weapons: { weapon: :weapon_series } },
{ summons: :summon } { summons: :summon }
) )
end end

View file

@ -265,7 +265,7 @@ class Party < ApplicationRecord
return false unless user return false unless user
Rails.cache.fetch("party_#{id}_favorited_by_#{user.id}", expires_in: 1.hour) do 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
end end