Merge pull request #10928 from colinux/perf-admin-index

ETQ admin, améliore un peu la vitesse de chargement de la liste des démarches
This commit is contained in:
Colin Darie 2024-10-14 11:34:48 +00:00 committed by GitHub
commit bac54ba214
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 43 additions and 39 deletions

View file

@ -24,43 +24,6 @@ module Administrateurs
@statut.blank? ? @statut = 'publiees' : @statut = params[:statut] @statut.blank? ? @statut = 'publiees' : @statut = params[:statut]
end end
def paginated_published_procedures
current_administrateur
.procedures
.publiees
.page(params[:page])
.per(ITEMS_PER_PAGE)
.order(published_at: :desc)
end
def paginated_draft_procedures
current_administrateur
.procedures
.brouillons
.page(params[:page])
.per(ITEMS_PER_PAGE)
.order(created_at: :desc)
end
def paginated_closed_procedures
current_administrateur
.procedures
.closes
.page(params[:page])
.per(ITEMS_PER_PAGE)
.order(created_at: :desc)
end
def paginated_deleted_procedures
current_administrateur
.procedures
.with_discarded
.discarded
.page(params[:page])
.per(ITEMS_PER_PAGE)
.order(created_at: :desc)
end
def apercu def apercu
@dossier = procedure_without_control.draft_revision.dossier_for_preview(current_user) @dossier = procedure_without_control.draft_revision.dossier_for_preview(current_user)
DossierPreloader.load_one(@dossier) DossierPreloader.load_one(@dossier)
@ -464,6 +427,47 @@ module Administrateurs
private private
def paginated_published_procedures
paginate_procedures(current_administrateur
.procedures
.publiees
.order(published_at: :desc))
end
def paginated_draft_procedures
paginate_procedures(current_administrateur
.procedures
.brouillons
.order(created_at: :desc))
end
def paginated_closed_procedures
paginate_procedures(current_administrateur
.procedures
.closes
.order(created_at: :desc))
end
def paginated_deleted_procedures
paginate_procedures(current_administrateur
.procedures
.with_discarded
.discarded
.order(created_at: :desc))
end
def paginate_procedures(procedures)
procedures
.with_attached_logo
.left_joins(groupe_instructeurs: :instructeurs)
.select('procedures.*,
COUNT(DISTINCT groupe_instructeurs.id) AS groupe_instructeurs_count,
COUNT(DISTINCT instructeurs.id) AS instructeurs_count')
.group('procedures.id')
.page(params[:page])
.per(ITEMS_PER_PAGE)
end
def filter_procedures(filter) def filter_procedures(filter)
if filter.service_siret.present? if filter.service_siret.present?
service = Service.find_by(siret: filter.service_siret) service = Service.find_by(siret: filter.service_siret)

View file

@ -45,9 +45,9 @@
%div %div
= dsfr_icon('fr-icon-team-fill') = dsfr_icon('fr-icon-team-fill')
- if procedure.routing_enabled? - if procedure.routing_enabled?
%span.fr-badge= procedure.groupe_instructeurs.count %span.fr-badge= procedure.groupe_instructeurs_count
- else - else
%span.fr-badge= procedure.instructeurs.count %span.fr-badge= procedure.instructeurs_count
= dsfr_icon('fr-icon-file-text-fill fr-ml-1w') = dsfr_icon('fr-icon-file-text-fill fr-ml-1w')
%span.fr-badge= procedure.dossiers.state_not_brouillon.visible_by_administration.count %span.fr-badge= procedure.dossiers.state_not_brouillon.visible_by_administration.count