fix: 4 less queries

This commit is contained in:
simon lehericey 2023-10-09 22:48:36 +02:00
parent 9861f16a05
commit 6d550802db
2 changed files with 5 additions and 6 deletions

View file

@ -20,10 +20,9 @@ module Users
check_prefilled_dossier_ownership if @prefilled_dossier check_prefilled_dossier_ownership if @prefilled_dossier
revision = @revision.draft? ? @revision : @procedure.revisions.where.not(id: @procedure.draft_revision_id) revision = @revision.draft? ? @revision : @procedure.revisions.where.not(id: @procedure.draft_revision_id)
@dossiers = current_user.dossiers.visible_by_user.where(revision:) @dossiers = current_user.dossiers.select(:id, :created_at, :depose_at, :state).visible_by_user.where(revision:).order(created_at: :desc).to_a
@drafts = @dossiers.brouillon @drafts, @not_drafts = @dossiers.partition(&:brouillon?)
@not_drafts = @dossiers.state_not_brouillon @preview_dossiers = @dossiers.take(3)
@preview_dossiers = @dossiers.order(created_at: :desc).limit(3)
end end
@usual_traitement_time = @procedure.stats_usual_traitement_time @usual_traitement_time = @procedure.stats_usual_traitement_time

View file

@ -28,7 +28,7 @@
= render Dsfr::CalloutComponent.new(title: t(".already_draft"), heading_level: 'h2') do |c| = render Dsfr::CalloutComponent.new(title: t(".already_draft"), heading_level: 'h2') do |c|
- c.body do - c.body do
%p %p
= t('.already_draft_detail_html', time_ago: time_ago_in_words(dossier.created_at), procedure: dossier.procedure.libelle) = t('.already_draft_detail_html', time_ago: time_ago_in_words(dossier.created_at), procedure: @procedure.libelle)
%ul.fr-btns-group.fr-btns-group--inline %ul.fr-btns-group.fr-btns-group--inline
%li= link_to t('.continue_file'), url_for_dossier(dossier), class: 'fr-btn' %li= link_to t('.continue_file'), url_for_dossier(dossier), class: 'fr-btn'
%li= link_to t('.start_new_file'), url_for_new_dossier(@revision), class: 'fr-btn fr-btn--secondary' %li= link_to t('.start_new_file'), url_for_new_dossier(@revision), class: 'fr-btn fr-btn--secondary'
@ -38,7 +38,7 @@
= render Dsfr::CalloutComponent.new(title: t(".already_not_draft"), heading_level: 'h2') do |c| = render Dsfr::CalloutComponent.new(title: t(".already_not_draft"), heading_level: 'h2') do |c|
- c.body do - c.body do
%p %p
= t('.already_not_draft_detail_html', time_ago: time_ago_in_words(dossier.depose_at), procedure: dossier.procedure.libelle) = t('.already_not_draft_detail_html', time_ago: time_ago_in_words(dossier.depose_at), procedure: @procedure.libelle)
%ul.fr-btns-group.fr-btns-group--inline %ul.fr-btns-group.fr-btns-group--inline
%li= link_to t('.show_my_submitted_file'), url_for_dossier(dossier), class: 'fr-btn' %li= link_to t('.show_my_submitted_file'), url_for_dossier(dossier), class: 'fr-btn'
%li= link_to t('.start_new_file'), url_for_new_dossier(@revision), class: 'fr-btn fr-btn--secondary' %li= link_to t('.start_new_file'), url_for_new_dossier(@revision), class: 'fr-btn fr-btn--secondary'