Merge pull request #6383 from betagouv/improve-repartition-par-semaine

Améliore le graphique "répartition par semaine" dans les statistiques d'une procédure
This commit is contained in:
krichtof 2021-08-10 15:37:30 +02:00 committed by GitHub
commit e1e6c2d5a8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 3 deletions

View file

@ -65,7 +65,6 @@ $stat-card-half-horizontal-spacing: 4 * $default-space;
.stat-card-details {
font-size: 13px;
text-align: center;
font-style: italic;
}

View file

@ -52,7 +52,12 @@ module ProcedureStatsConcern
# rubocop:disable Style/HashTransformValues
dossier_state_values
.map do |state|
{ name: state, data: chart_data.where(state: state).group_by_week { |dossier| dossier.traitements.first.processed_at }.map { |k, v| [k, v.count] }.to_h }
{
name: state,
data: chart_data .where(state: state) .group_by_week do |dossier|
dossier.traitements.first.processed_at
end.map { |k, v| [k, v.count] }.to_h.transform_keys { |week| pretty_week(week) }
}
# rubocop:enable Style/HashTransformValues
end
end
@ -104,4 +109,8 @@ module ProcedureStatsConcern
def pretty_month(month)
I18n.l(month, format: "%B %Y")
end
def pretty_week(week)
I18n.l(week, format: '%d %b')
end
end

View file

@ -37,6 +37,7 @@
.stat-card.stat-card-half.pull-left
%span.stat-card-title RÉPARTITION PAR SEMAINE
.stat-card-details au cours des 6 derniers mois
.chart-container
.chart
= line_chart @termines_by_week, colors: ["#387EC3", "#AE2C2B", "#FAD859"]
= line_chart @termines_by_week, colors: ["#387EC3", "#AE2C2B", "#FAD859"], ytitle: 'Nb dossiers'