stats: rend plus explicite le graphe taux d'acceptation

This commit is contained in:
Christophe Robillard 2021-08-10 17:37:42 +02:00
parent e1e6c2d5a8
commit 93ba0cc038
2 changed files with 16 additions and 4 deletions

View file

@ -31,11 +31,12 @@ module ProcedureStatsConcern
end
def stats_termines_states
nb_dossiers_termines = dossiers.state_termine.count
Rails.cache.fetch("#{cache_key_with_version}/stats_termines_states", expires_in: 12.hours) do
[
['Acceptés', dossiers.where(state: :accepte).count],
['Refusés', dossiers.where(state: :refuse).count],
['Classés sans suite', dossiers.where(state: :sans_suite).count]
['Acceptés', percentage(dossiers.where(state: :accepte).count, nb_dossiers_termines)],
['Refusés', percentage(dossiers.where(state: :refuse).count, nb_dossiers_termines)],
['Classés sans suite', percentage(dossiers.where(state: :sans_suite).count, nb_dossiers_termines)]
]
end
end
@ -106,6 +107,10 @@ module ProcedureStatsConcern
(seconds / 60.0 / 60.0 / 24.0).ceil
end
def percentage(value, total)
(100 * value / total.to_f).round(1)
end
def pretty_month(month)
I18n.l(month, format: "%B %Y")
end

View file

@ -30,10 +30,17 @@
.stat-cards
.stat-card.stat-card-half.pull-left
%span.stat-card-title TAUX DACCEPTATION
.stat-card-details depuis le lancement de la procédure
.chart-container
.chart
- colors = %w(#C3D9FF #0069CC #1C7EC9) # from _colors.scss
= pie_chart @termines_states, colors: colors
= pie_chart @termines_states,
code: true,
colors: colors,
label: 'Taux',
suffix: '%',
library: { plotOptions: { pie: { dataLabels: { enabled: true, format: '{point.name} : {point.percentage: .1f}%' } } } }
.stat-card.stat-card-half.pull-left
%span.stat-card-title RÉPARTITION PAR SEMAINE