Merge pull request #10969 from tchak/fix-dossier-preloader-with-champs-outside-of-revision

fix(dossier): fix preloader with champs outside of revision
This commit is contained in:
Paul Chavard 2024-10-21 08:11:17 +00:00 committed by GitHub
commit 79711f6901
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -63,7 +63,8 @@ class DossierPreloader
def load_etablissements(champs)
to_include = @includes_for_etablissement.dup
champs_siret = champs.filter(&:siret?)
# `champs.siret?` will delegate to type_de_champ; this is not what we want here
champs_siret = champs.filter { _1.type == 'Champs::SiretChamp' }
etablissements_by_id = Etablissement.includes(to_include).where(id: champs_siret.map(&:etablissement_id).compact).index_by(&:id)
champs_siret.each do |champ|
etablissement = etablissements_by_id[champ.etablissement_id]