From 358c08ec2951351b1b83da359e55cab52b0f973f Mon Sep 17 00:00:00 2001 From: pedong Date: Thu, 24 Jan 2019 14:57:21 +0100 Subject: [PATCH 1/5] [fix #3282] add empty value for type_champ datatime --- app/views/shared/dossiers/editable_champs/_datetime.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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) From 41ae1f46f4f3dd97af411fcb08f07ff0b22589eb Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Fri, 1 Feb 2019 10:54:20 +0100 Subject: [PATCH 2/5] Trusted_device: cleaner time comparison --- app/models/concerns/trusted_device_concern.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 From 34a2dc6b9707a2d15ae2f6501d86b3770cc5a088 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Mon, 28 Jan 2019 14:16:41 +0000 Subject: [PATCH 3/5] stats: turn satisfaction into a stacked area chart --- app/controllers/stats_controller.rb | 8 ++++---- app/views/stats/index.html.haml | 6 ++++-- 2 files changed, 8 insertions(+), 6 deletions(-) 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/views/stats/index.html.haml b/app/views/stats/index.html.haml index 80b46b8d6..c0483ce45 100644 --- a/app/views/stats/index.html.haml +++ b/app/views/stats/index.html.haml @@ -25,8 +25,10 @@ .chart-container .chart - = line_chart @satisfaction_usagers, - colors: ["#15AD70", "#F28900", "rgba(161, 0, 5, 0.9)"] + = area_chart @satisfaction_usagers, + stacked: true, + max: 100, + colors: ["#BD0107", "#F28900", "#15AD70"] .stat-card.stat-card-half.pull-left %span.stat-card-title From 283f110e9bc465acc7e70ae594c240835c3f972e Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Mon, 28 Jan 2019 15:17:06 +0100 Subject: [PATCH 4/5] stats: improve numeric separators and suffixes --- app/views/stats/index.html.haml | 1 + config/initializers/chartkick.rb | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/views/stats/index.html.haml b/app/views/stats/index.html.haml index c0483ce45..6db06810e 100644 --- a/app/views/stats/index.html.haml +++ b/app/views/stats/index.html.haml @@ -27,6 +27,7 @@ .chart = area_chart @satisfaction_usagers, stacked: true, + suffix: ' %', max: 100, colors: ["#BD0107", "#F28900", "#15AD70"] 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: ',' } From f42d9fce0c991ced854952988a368b2f536e7c50 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Mon, 28 Jan 2019 19:04:29 +0100 Subject: [PATCH 5/5] stats: add data points to the user satisfaction --- app/views/stats/index.html.haml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/stats/index.html.haml b/app/views/stats/index.html.haml index 6db06810e..fc10a6309 100644 --- a/app/views/stats/index.html.haml +++ b/app/views/stats/index.html.haml @@ -29,7 +29,8 @@ stacked: true, suffix: ' %', max: 100, - colors: ["#BD0107", "#F28900", "#15AD70"] + library: { plotOptions: { series: { marker: { enabled: true }}}}, + colors: ["#C31C25", "#F5962A", "#25B177"] .stat-card.stat-card-half.pull-left %span.stat-card-title