stats: display 12 weeks of feedbacks

This commit is contained in:
Pierre de La Morinerie 2019-04-02 14:29:00 +02:00
parent 78867e5679
commit 031c40aa55
2 changed files with 10 additions and 13 deletions

View file

@ -132,7 +132,7 @@ class StatsController < ApplicationController
Feedback.ratings.fetch(:happy) => "Satisfaits"
}
number_of_weeks = 6
number_of_weeks = 12
totals = Feedback
.group_by_week(:created_at, last: number_of_weeks, current: false)
.count

View file

@ -228,20 +228,17 @@ describe StatsController, type: :controller do
it 'returns weekly ratios between a given feedback and all feedback' do
happy_data = stats.find { |g| g[:name] == 'Satisfaits' }[:data]
expect(happy_data.values[0]).to eq 0
expect(happy_data.values[1]).to eq 0
expect(happy_data.values[2]).to eq 0
expect(happy_data.values[3]).to eq 25.0
expect(happy_data.values[4]).to eq 50.0
expect(happy_data.values[5]).to eq 75.0
expect(happy_data.values[-4]).to eq 0
expect(happy_data.values[-3]).to eq 25.0
expect(happy_data.values[-2]).to eq 50.0
expect(happy_data.values[-1]).to eq 75.0
unhappy_data = stats.find { |g| g[:name] == 'Mécontents' }[:data]
expect(unhappy_data.values[0]).to eq 0
expect(unhappy_data.values[1]).to eq 0
expect(unhappy_data.values[2]).to eq 0
expect(unhappy_data.values[3]).to eq 75.0
expect(unhappy_data.values[4]).to eq 50.0
expect(unhappy_data.values[5]).to eq 25.0
expect(unhappy_data.values[-4]).to eq 0
expect(unhappy_data.values[-3]).to eq 75.0
expect(unhappy_data.values[-2]).to eq 50.0
expect(unhappy_data.values[-1]).to eq 25.0
end
it 'excludes values still in the current week' do