diff --git a/app/controllers/stats_controller.rb b/app/controllers/stats_controller.rb index 196c292d6..5a7579fa7 100644 --- a/app/controllers/stats_controller.rb +++ b/app/controllers/stats_controller.rb @@ -129,9 +129,9 @@ class StatsController < ApplicationController def satisfaction_usagers legend = { - Feedback.ratings.fetch(:happy) => "Satisfaits", - Feedback.ratings.fetch(:neutral) => "Neutres", - Feedback.ratings.fetch(:unhappy) => "Mécontents" + Feedback.ratings.fetch(:unhappy) => "Mécontents", + Feedback.ratings.fetch(:neutral) => "Neutres", + Feedback.ratings.fetch(:happy) => "Satisfaits" } number_of_weeks = 6 @@ -139,7 +139,7 @@ class StatsController < ApplicationController .group_by_week(:created_at, last: number_of_weeks, current: false) .count - Feedback.ratings.values.map do |rating| + legend.keys.map do |rating| data = Feedback .where(rating: rating) .group_by_week(:created_at, last: number_of_weeks, current: false) diff --git a/app/models/concerns/trusted_device_concern.rb b/app/models/concerns/trusted_device_concern.rb index 5aff22882..9928adfa1 100644 --- a/app/models/concerns/trusted_device_concern.rb +++ b/app/models/concerns/trusted_device_concern.rb @@ -14,11 +14,15 @@ module TrustedDeviceConcern def trusted_device? trusted_device_cookie.present? && - Time.zone.now - TRUSTED_DEVICE_PERIOD < JSON.parse(trusted_device_cookie)['created_at'] + (Time.zone.now - TRUSTED_DEVICE_PERIOD) < trusted_device_cookie_created_at end private + def trusted_device_cookie_created_at + Time.zone.parse(JSON.parse(trusted_device_cookie)['created_at']) + end + def trusted_device_cookie cookies.encrypted[TRUSTED_DEVICE_COOKIE_NAME] end diff --git a/app/views/shared/dossiers/editable_champs/_datetime.html.haml b/app/views/shared/dossiers/editable_champs/_datetime.html.haml index 4eb9c2109..a64ad3671 100644 --- a/app/views/shared/dossiers/editable_champs/_datetime.html.haml +++ b/app/views/shared/dossiers/editable_champs/_datetime.html.haml @@ -1,4 +1,4 @@ -- parsed_value = champ.value.present? ? Time.zone.parse(champ.value) : Time.zone.now +- parsed_value = champ.value.present? ? Time.zone.parse(champ.value) : nil .datetime - = form.datetime_select(:value, selected: parsed_value, start_year: 1950, end_year: 2100, minute_step: 5) + = form.datetime_select(:value, selected: parsed_value, start_year: 1950, end_year: 2100, minute_step: 5, include_blank: true) diff --git a/app/views/stats/index.html.haml b/app/views/stats/index.html.haml index 80b46b8d6..fc10a6309 100644 --- a/app/views/stats/index.html.haml +++ b/app/views/stats/index.html.haml @@ -25,8 +25,12 @@ .chart-container .chart - = line_chart @satisfaction_usagers, - colors: ["#15AD70", "#F28900", "rgba(161, 0, 5, 0.9)"] + = area_chart @satisfaction_usagers, + stacked: true, + suffix: ' %', + max: 100, + library: { plotOptions: { series: { marker: { enabled: true }}}}, + colors: ["#C31C25", "#F5962A", "#25B177"] .stat-card.stat-card-half.pull-left %span.stat-card-title diff --git a/config/initializers/chartkick.rb b/config/initializers/chartkick.rb index 213fa9164..cf507c8be 100644 --- a/config/initializers/chartkick.rb +++ b/config/initializers/chartkick.rb @@ -1,5 +1,7 @@ Chartkick.options = { content_for: :charts_js, defer: true, - colors: ["rgba(61, 149, 236, 1)"] + colors: ["rgba(61, 149, 236, 1)"], + thousands: ' ', + decimal: ',' }