perf(dossier): memoize champ.sections on dossier
This commit is contained in:
parent
51af70639b
commit
c60a8970f1
3 changed files with 36 additions and 19 deletions
|
@ -1122,6 +1122,20 @@ class Dossier < ApplicationRecord
|
|||
termine_expired_to_delete.find_each(&:purge_discarded)
|
||||
end
|
||||
|
||||
def sections_for(champ)
|
||||
@sections = Hash.new do |hash, parent|
|
||||
case parent
|
||||
when :public
|
||||
hash[parent] = champs.filter(&:header_section?)
|
||||
when :private
|
||||
hash[parent] = champs_private.filter(&:header_section?)
|
||||
else
|
||||
hash[parent] = parent.champs.filter(&:header_section?)
|
||||
end
|
||||
end
|
||||
@sections[champ.parent || (champ.public? ? :public : :private)]
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def create_missing_traitemets
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue