Update the stats code to use ratings instead of marks
This commit is contained in:
parent
3ba4ce0d37
commit
18624ff872
1 changed files with 6 additions and 6 deletions
|
@ -89,16 +89,16 @@ class StatsController < ApplicationController
|
||||||
|
|
||||||
def satisfaction_usagers
|
def satisfaction_usagers
|
||||||
legend = {
|
legend = {
|
||||||
"0" => "Mécontents",
|
Feedback.ratings.fetch(:unhappy) => "Mécontents",
|
||||||
"1" => "Neutres",
|
Feedback.ratings.fetch(:neutral) => "Neutres",
|
||||||
"2" => "Satisfaits"
|
Feedback.ratings.fetch(:happy) => "Satisfaits"
|
||||||
}
|
}
|
||||||
|
|
||||||
totals = Feedback.where(created_at: 5.weeks.ago..Time.now).group_by_week(:created_at).count
|
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
|
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)
|
.group_by_week(:created_at)
|
||||||
.count
|
.count
|
||||||
.map do |week, count|
|
.map do |week, count|
|
||||||
|
@ -112,7 +112,7 @@ class StatsController < ApplicationController
|
||||||
end.to_h
|
end.to_h
|
||||||
|
|
||||||
{
|
{
|
||||||
name: legend[mark.to_s],
|
name: legend[rating],
|
||||||
data: data
|
data: data
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue