Merge pull request #9311 from demarches-simplifiees/perf_admin
Perf: améliorer la perf de la page admin en cachant le résultat du parseur de template
This commit is contained in:
commit
cb76210707
2 changed files with 12 additions and 11 deletions
|
@ -114,8 +114,6 @@ module Administrateurs
|
|||
.find(params[:id])
|
||||
|
||||
@procedure.validate(:publication)
|
||||
|
||||
@current_administrateur = current_administrateur
|
||||
end
|
||||
|
||||
def edit
|
||||
|
|
|
@ -354,15 +354,18 @@ module TagsSubstitutionConcern
|
|||
end
|
||||
|
||||
def used_tags_and_libelle_for(text)
|
||||
parse_tags(text).filter_map do |token|
|
||||
case token
|
||||
in { tag: tag, id: id }
|
||||
[id, tag]
|
||||
in { tag: tag }
|
||||
[tag]
|
||||
else
|
||||
nil
|
||||
end
|
||||
# MD5 should be enough and it avoids long key
|
||||
Rails.cache.fetch(["parse_tags", Digest::MD5.hexdigest(text)], expires_in: 1.day) do
|
||||
parse_tags(text).filter_map do |token|
|
||||
case token
|
||||
in { tag: tag, id: id }
|
||||
[id, tag]
|
||||
in { tag: tag }
|
||||
[tag]
|
||||
else
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue