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:
Paul Chavard 2023-07-19 11:34:50 +00:00 committed by GitHub
commit cb76210707
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 11 deletions

View file

@ -114,8 +114,6 @@ module Administrateurs
.find(params[:id])
@procedure.validate(:publication)
@current_administrateur = current_administrateur
end
def edit

View file

@ -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