Merge pull request #7828 from betagouv/improve_admin_procedure_perf

perf: amélioration de la rapidité de la page admin/procedure/show
This commit is contained in:
LeSim 2022-10-03 21:01:52 +02:00 committed by GitHub
commit ffb81e6d72
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 6 deletions

View file

@ -1,7 +1,6 @@
class Procedure::Card::AnnotationsComponent < ApplicationComponent
def initialize(procedure:)
@procedure = procedure
@procedure.validate(:publication)
@count = @procedure.draft_revision.types_de_champ.private_only.size
end

View file

@ -1,7 +1,6 @@
class Procedure::Card::ChampsComponent < ApplicationComponent
def initialize(procedure:)
@procedure = procedure
@procedure.validate(:publication)
@count = @procedure.draft_revision.types_de_champ.public_only.size
end

View file

@ -93,11 +93,13 @@ module Administrateurs
@procedure = current_administrateur
.procedures
.includes(
published_revision: { revision_types_de_champ: :type_de_champ },
draft_revision: { revision_types_de_champ: :type_de_champ }
published_revision: :types_de_champ,
draft_revision: :types_de_champ
)
.find(params[:id])
@procedure.validate(:publication)
@current_administrateur = current_administrateur
@procedure_lien = commencer_url(path: @procedure.path)
@procedure_lien_test = commencer_test_url(path: @procedure.path)
@ -233,6 +235,13 @@ module Administrateurs
end
def publication
@procedure = current_administrateur
.procedures
.includes(
published_revision: :types_de_champ,
draft_revision: :types_de_champ
).find(params[:procedure_id])
@procedure_lien = commencer_url(path: @procedure.path)
@procedure_lien_test = commencer_test_url(path: @procedure.path)
@procedure.path = @procedure.suggested_path(current_administrateur)

View file

@ -4,8 +4,9 @@
- else
- changes.filter { |change| change[:model] == :attestation_template }.each do |change|
= render partial: 'administrateurs/procedures/revision_change_attestation_template', locals: { change: change }
- changes.filter { |change| change[:model] == :type_de_champ }.each do |change|
= render partial: 'administrateurs/procedures/revision_change_type_de_champ', locals: { change: change }
= render partial: "administrateurs/procedures/revision_change_type_de_champ",
collection: changes.filter { |change| change[:model] == :type_de_champ },
as: :change
- move_changes, move_private_changes = changes.filter { |change| change[:op] == :move }.partition { |change| !change[:private] }
- if move_changes.present?
%li.mb-1= t(:move, scope: [:administrateurs, :revision_changes], count: move_changes.size)