Merge pull request #3723 from betagouv/improve-stats
Améliorations de la page /stats
This commit is contained in:
commit
b8c309acdb
2 changed files with 13 additions and 14 deletions
|
@ -132,7 +132,7 @@ class StatsController < ApplicationController
|
||||||
Feedback.ratings.fetch(:happy) => "Satisfaits"
|
Feedback.ratings.fetch(:happy) => "Satisfaits"
|
||||||
}
|
}
|
||||||
|
|
||||||
number_of_weeks = 6
|
number_of_weeks = 12
|
||||||
totals = Feedback
|
totals = Feedback
|
||||||
.group_by_week(:created_at, last: number_of_weeks, current: false)
|
.group_by_week(:created_at, last: number_of_weeks, current: false)
|
||||||
.count
|
.count
|
||||||
|
@ -162,7 +162,9 @@ class StatsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def contact_percentage
|
def contact_percentage
|
||||||
from = Date.new(2018, 1)
|
number_of_months = 13
|
||||||
|
|
||||||
|
from = Date.today.prev_month(number_of_months)
|
||||||
to = Date.today.prev_month
|
to = Date.today.prev_month
|
||||||
|
|
||||||
adapter = Helpscout::UserConversationsAdapter.new(from, to)
|
adapter = Helpscout::UserConversationsAdapter.new(from, to)
|
||||||
|
|
|
@ -228,20 +228,17 @@ describe StatsController, type: :controller do
|
||||||
|
|
||||||
it 'returns weekly ratios between a given feedback and all feedback' do
|
it 'returns weekly ratios between a given feedback and all feedback' do
|
||||||
happy_data = stats.find { |g| g[:name] == 'Satisfaits' }[:data]
|
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[-4]).to eq 0
|
||||||
expect(happy_data.values[2]).to eq 0
|
expect(happy_data.values[-3]).to eq 25.0
|
||||||
expect(happy_data.values[3]).to eq 25.0
|
expect(happy_data.values[-2]).to eq 50.0
|
||||||
expect(happy_data.values[4]).to eq 50.0
|
expect(happy_data.values[-1]).to eq 75.0
|
||||||
expect(happy_data.values[5]).to eq 75.0
|
|
||||||
|
|
||||||
unhappy_data = stats.find { |g| g[:name] == 'Mécontents' }[:data]
|
unhappy_data = stats.find { |g| g[:name] == 'Mécontents' }[:data]
|
||||||
expect(unhappy_data.values[0]).to eq 0
|
expect(unhappy_data.values[-4]).to eq 0
|
||||||
expect(unhappy_data.values[1]).to eq 0
|
expect(unhappy_data.values[-3]).to eq 75.0
|
||||||
expect(unhappy_data.values[2]).to eq 0
|
expect(unhappy_data.values[-2]).to eq 50.0
|
||||||
expect(unhappy_data.values[3]).to eq 75.0
|
expect(unhappy_data.values[-1]).to eq 25.0
|
||||||
expect(unhappy_data.values[4]).to eq 50.0
|
|
||||||
expect(unhappy_data.values[5]).to eq 25.0
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'excludes values still in the current week' do
|
it 'excludes values still in the current week' do
|
||||||
|
|
Loading…
Reference in a new issue