perf(dossier): memoize champ.sections on dossier

This commit is contained in:
Paul Chavard 2022-03-10 19:22:07 +01:00
parent 51af70639b
commit c60a8970f1
3 changed files with 36 additions and 19 deletions

View file

@ -81,18 +81,8 @@ class Champ < ApplicationRecord
!private?
end
def siblings
if parent
parent&.champs
elsif public?
dossier&.champs
else
dossier&.champs_private
end
end
def sections
siblings&.filter(&:header_section?)
@sections ||= dossier.sections_for(self)
end
def mandatory_and_blank?