Skip to content

Commit 1a5464a

Browse files
authored
Merge pull request #13335 from mfo/rework-stats
Amelioration: ETQ instructeur, afficher les délais d'instruction estimés aux usagers + Tech: migration HAML → ERB stats
2 parents 1a5f2cc + ea518d5 commit 1a5464a

26 files changed

Lines changed: 343 additions & 100 deletions

app/components/procedure/estimated_delay_component.rb

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,47 @@
33
class Procedure::EstimatedDelayComponent < ApplicationComponent
44
delegate :distance_of_time_in_words, to: :helpers
55

6-
def initialize(procedure:)
6+
def initialize(procedure:, fallback_to_placeholder: false)
77
@procedure = procedure
8+
@fallback_to_placeholder = fallback_to_placeholder
89
@fastest, @mean, @slow = @procedure.stats_usual_traitement_time
910
end
1011

1112
def estimation_present?
1213
@fastest && @mean && @slow
1314
end
1415

16+
def placeholder_mode?
17+
!estimation_present? && @procedure.brouillon?
18+
end
19+
1520
def render?
1621
return false if @procedure.declarative_accepte?
1722

18-
estimation_present?
23+
if @fallback_to_placeholder
24+
estimation_present? || placeholder_mode?
25+
else
26+
@procedure.estimated_processing_duration_visible? && estimation_present?
27+
end
28+
end
29+
30+
def placeholder_estimation(key)
31+
tag.span(t(key), class: 'fr-text-default--info')
1932
end
2033

21-
def cleaned_nearby_estimation
22-
[@fastest, @mean, @slow]
23-
.map { distance_of_time_in_words(_1) }
24-
.uniq
25-
.zip(['fast_html', 'mean_html', 'slow_html'])
26-
.each do |estimation, i18n_key|
27-
yield(estimation, i18n_key)
28-
end
34+
def cleaned_nearby_estimation(&block)
35+
if placeholder_mode?
36+
yield(placeholder_estimation('.placeholder_delay'), 'fast_html')
37+
yield(placeholder_estimation('.placeholder_delay_mean'), 'mean_html')
38+
yield(placeholder_estimation('.placeholder_delay_mean'), 'slow_html')
39+
else
40+
[@fastest, @mean, @slow]
41+
.map { distance_of_time_in_words(_1) }
42+
.uniq
43+
.zip(['fast_html', 'mean_html', 'slow_html'])
44+
.each do |estimation, i18n_key|
45+
yield(estimation, i18n_key)
46+
end
47+
end
2948
end
3049
end
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
---
22
en:
33
explanation: 'Based on %{percentile}% during the last %{nb_recent_dossiers} days, the instruction time is :'
4-
fast_html: '<strong>In the best case scenario</strong> : <strong>%{estimation}</strong>.'
5-
mean_html: 'If your file <strong>requires minor adjustments</strong>, the instruction time is <strong>%{estimation}</strong>.'
6-
slow_html: 'If you file <strong>is missing some information</strong> which requires a lot of exchanges with the administration, the instruction time is around <strong>%{estimation}</strong>.'
4+
fast_html: '<strong>In the best case scenario</strong>, the instruction time is <strong>%{estimation}</strong>.'
5+
mean_html: '<strong>For files requiring minor adjustments</strong>, the instruction time is around <strong>%{estimation}</strong>.'
6+
slow_html: 'If your file <strong>is missing some information</strong> which requires a lot of exchanges with the administration, the instruction time is around <strong>%{estimation}</strong>.'
7+
placeholder_delay: "[delay indication]"
8+
placeholder_delay_mean: "[average delay indication]"
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
---
22
fr:
33
explanation: Selon nos estimations, à partir des délais d’instruction constatés sur %{percentile}% des demandes qui ont été traitées lors des %{nb_recent_dossiers} derniers jours, les délais d’instruction sont les suivants
4-
fast_html: "<strong>Dans le meilleur des cas</strong>, le délai d’instruction est : <strong>%{estimation}</strong>."
5-
mean_html: "Les <strong>dossiers demandant quelques échanges</strong> le délai d’instruction est d’environ : <strong>%{estimation}</strong>."
4+
fast_html: "<strong>Dans le meilleur des cas</strong>, le délai d’instruction est de <strong>%{estimation}</strong>."
5+
mean_html: "<strong>Pour les dossiers demandant quelques échanges</strong>, le délai d’instruction est d’environ <strong>%{estimation}</strong>."
66
slow_html: "Si votre <strong>dossier est incomplet</strong> ou qu’il faut beaucoup d’échanges avec l’administration, le délai d’instruction est d’environ <strong>%{estimation}</strong>."
7+
placeholder_delay: "[indication du délai]"
8+
placeholder_delay_mean: "[indication du délai moyen]"

app/dashboards/procedure_dashboard.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ class ProcedureDashboard < Administrate::BaseDashboard
5050
duree_conservation_dossiers_dans_ds: Field::Number,
5151
max_duree_conservation_dossiers_dans_ds: Field::Number,
5252
estimated_duration_visible: Field::Boolean,
53+
estimated_processing_duration_visible: Field::Boolean,
5354
piece_justificative_multiple: Field::Boolean,
5455
for_tiers_enabled: Field::Boolean,
5556
replaced_by_procedure_id: Field::String,
@@ -127,6 +128,7 @@ class ProcedureDashboard < Administrate::BaseDashboard
127128
:duree_conservation_dossiers_dans_ds,
128129
:max_duree_conservation_dossiers_dans_ds,
129130
:estimated_duration_visible,
131+
:estimated_processing_duration_visible,
130132
:piece_justificative_multiple,
131133
:for_tiers_enabled,
132134
:hide_instructeurs_email,
@@ -143,6 +145,7 @@ class ProcedureDashboard < Administrate::BaseDashboard
143145
:duree_conservation_dossiers_dans_ds,
144146
:max_duree_conservation_dossiers_dans_ds,
145147
:estimated_duration_visible,
148+
:estimated_processing_duration_visible,
146149
:piece_justificative_multiple,
147150
:for_tiers_enabled,
148151
:hide_instructeurs_email,

app/models/concerns/procedure_clone_concern.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ module ProcedureCloneConcern
5656
'tags',
5757
'piece_justificative_multiple',
5858
'estimated_duration_visible',
59+
'estimated_processing_duration_visible',
5960
'estimated_dossiers_count',
6061
'dossiers_count_computed_at',
6162
'allow_expert_messaging',
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<% title = t('instructeurs.dossiers.header.banner.statistics') -%>
2+
<% content_for(:title, title) -%>
3+
4+
<div class="sub-header">
5+
<div class="fr-container flex column">
6+
<%= render partial: 'shared/breadcrumbs',
7+
locals: { steps: [[t('show_procedure', scope: [:layouts, :breadcrumb], libelle: @procedure.libelle.truncate(22)), instructeur_procedure_path(@procedure)],
8+
[t('instructeurs.dossiers.header.banner.statistics')]] } %>
9+
10+
<%= render partial: 'instructeurs/procedures/header',
11+
locals: { procedure: @procedure } %>
12+
</div>
13+
</div>
14+
15+
<%= render partial: 'shared/procedures/stats', locals: { title: title, show_user_indication: true } %>

app/views/instructeurs/procedures/stats.html.haml

Lines changed: 0 additions & 13 deletions
This file was deleted.

app/views/shared/_procedure_description.html.haml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
%ul
6363
= render partial: "shared/procedure_pieces_jointes_list", collection: pj_with_condition, as: :pj
6464
65-
- estimated_delay_component = Procedure::EstimatedDelayComponent.new(procedure: procedure)
65+
- estimated_delay_component = Procedure::EstimatedDelayComponent.new(procedure: procedure, fallback_to_placeholder: current_administrateur&.in?(procedure.administrateurs))
6666
- if estimated_delay_component.render?
6767
%section.fr-accordion
6868
%h2.fr-accordion__title
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
<div class="fr-container fr-my-4w">
2+
<h1 class="fr-h4"><%= title %></h1>
3+
4+
<div class="fr-grid-row fr-grid-row--gutters">
5+
<% if @usual_traitement_time.present? && (local_assigns[:show_user_indication] || @procedure.estimated_processing_duration_visible?) -%>
6+
<div class="fr-col-xs-12">
7+
<div class="fr-callout">
8+
<h2 class="fr-callout__title">
9+
<%= t('.usual_processing_time') %>
10+
11+
<% if local_assigns[:show_user_indication] -%>
12+
<%= t('.user_indication') %>
13+
<% end -%>
14+
</h2>
15+
16+
<%= render Procedure::EstimatedDelayComponent.new(procedure: @procedure, fallback_to_placeholder: local_assigns[:show_user_indication]) %>
17+
</div>
18+
</div>
19+
<% end -%>
20+
21+
<div class="fr-col-xs-12 fr-col-sm-12 fr-col-lg-6">
22+
<div class="fr-callout" data-controller="chartkick">
23+
<h2 class="fr-callout__title"><%= t('.processing_time') %></h2>
24+
25+
<p class="fr-callout__text fr-text--md">
26+
<%= t('.since_procedure_creation') %>
27+
</p>
28+
29+
<div class="fr-mt-4w">
30+
<div class="chart-procedures-chart" data-chartkick-target="chart">
31+
<%= column_chart @usual_traitement_time_by_month,
32+
library: Chartkick.options[:default_library_config],
33+
ytitle: t('.nb_days'), legend: "bottom", label: t('.processing_time_graph_description') %>
34+
</div>
35+
</div>
36+
</div>
37+
</div>
38+
39+
<div class="fr-col-xs-12 fr-col-sm-12 fr-col-lg-6">
40+
<div class="fr-callout">
41+
<h2 class="fr-callout__title"><%= t('.status_evolution') %></h2>
42+
43+
<p class="fr-callout__text fr-text--md">
44+
<%= t('.status_evolution_details') %>
45+
</p>
46+
47+
<div class="fr-mt-4w">
48+
<div class="chart">
49+
<%= area_chart @dossiers_funnel,
50+
library: Chartkick.options[:default_library_config],
51+
ytitle: t('.dossiers_count'), label: t('.dossiers_count') %>
52+
</div>
53+
</div>
54+
</div>
55+
</div>
56+
57+
<div class="fr-col-xs-12 fr-col-sm-12 fr-col-lg-6">
58+
<div class="fr-callout">
59+
<h2 class="fr-callout__title"><%= t('.acceptance_rate') %></h2>
60+
61+
<p class="fr-callout__text fr-text--md">
62+
<%= t('.acceptance_rate_details') %>
63+
</p>
64+
65+
<div class="fr-mt-4w">
66+
<div class="chart">
67+
<%= pie_chart @termines_states,
68+
library: Chartkick.options[:default_library_config],
69+
code: true,
70+
colors: ["var(--background-flat-success)", "var(--background-flat-error)", "#FAD859"],
71+
label: t('.rate'),
72+
suffix: '%' %>
73+
</div>
74+
</div>
75+
</div>
76+
</div>
77+
78+
<div class="fr-col-xs-12 fr-col-sm-12 fr-col-lg-6">
79+
<div class="fr-callout">
80+
<h2 class="fr-callout__title"><%= t('.weekly_distribution') %></h2>
81+
82+
<p class="fr-callout__text fr-text--md">
83+
<%= t('.weekly_distribution_details') %>
84+
</p>
85+
86+
<div class="fr-mt-4w">
87+
<div class="chart">
88+
<%= line_chart @termines_by_week,
89+
library: Chartkick.options[:default_library_config],
90+
colors: ["var(--background-flat-success)", "var(--background-flat-error)", "#FAD859"],
91+
ytitle: t('.dossiers_count') %>
92+
</div>
93+
</div>
94+
</div>
95+
</div>
96+
</div>
97+
</div>

app/views/shared/procedures/_stats.html.haml

Lines changed: 0 additions & 56 deletions
This file was deleted.

0 commit comments

Comments
 (0)