From 18624ff8723e954a6142d6141ed9b6164dd71f9b Mon Sep 17 00:00:00 2001 From: gregoirenovel Date: Mon, 27 Aug 2018 14:12:38 +0200 Subject: [PATCH] Update the stats code to use ratings instead of marks --- app/controllers/stats_controller.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/controllers/stats_controller.rb b/app/controllers/stats_controller.rb index 11de1eaa5..7b5605e0e 100644 --- a/app/controllers/stats_controller.rb +++ b/app/controllers/stats_controller.rb @@ -89,16 +89,16 @@ class StatsController < ApplicationController def satisfaction_usagers legend = { - "0" => "Mécontents", - "1" => "Neutres", - "2" => "Satisfaits" + Feedback.ratings.fetch(:unhappy) => "Mécontents", + Feedback.ratings.fetch(:neutral) => "Neutres", + Feedback.ratings.fetch(:happy) => "Satisfaits" } totals = Feedback.where(created_at: 5.weeks.ago..Time.now).group_by_week(:created_at).count - (0..2).map do |mark| + Feedback::rating.values.map do |rating| data = Feedback - .where(created_at: 5.weeks.ago..Time.now, mark: mark) + .where(created_at: 5.weeks.ago..Time.now, rating: rating) .group_by_week(:created_at) .count .map do |week, count| @@ -112,7 +112,7 @@ class StatsController < ApplicationController end.to_h { - name: legend[mark.to_s], + name: legend[rating], data: data } end