Merge pull request #6105 from tchak/remove-feedback
Remove user feedback buttons
This commit is contained in:
commit
684fb388d3
12 changed files with 0 additions and 211 deletions
|
@ -1,16 +0,0 @@
|
|||
@import "colors";
|
||||
@import "constants";
|
||||
|
||||
#user-satisfaction {
|
||||
text-align: center;
|
||||
padding: 20px;
|
||||
|
||||
.icon {
|
||||
padding: 10px 5px;
|
||||
margin: 10px 10px;
|
||||
|
||||
&:hover {
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -17,8 +17,6 @@ class StatsController < ApplicationController
|
|||
stat.dossiers_deposes_entre_60_et_30_jours
|
||||
)
|
||||
|
||||
@satisfaction_usagers = satisfaction_usagers
|
||||
|
||||
@contact_percentage = contact_percentage
|
||||
|
||||
@dossiers_states_for_pie = {
|
||||
|
@ -123,42 +121,6 @@ class StatsController < ApplicationController
|
|||
}
|
||||
end
|
||||
|
||||
def satisfaction_usagers
|
||||
legend = {
|
||||
Feedback.ratings.fetch(:unhappy) => "Mécontents",
|
||||
Feedback.ratings.fetch(:neutral) => "Neutres",
|
||||
Feedback.ratings.fetch(:happy) => "Satisfaits"
|
||||
}
|
||||
|
||||
number_of_weeks = 12
|
||||
totals = Feedback
|
||||
.group_by_week(:created_at, last: number_of_weeks, current: false)
|
||||
.count
|
||||
|
||||
legend.keys.map do |rating|
|
||||
data = Feedback
|
||||
.where(rating: rating)
|
||||
.group_by_week(:created_at, last: number_of_weeks, current: false)
|
||||
.count
|
||||
.map do |week, count|
|
||||
total = totals[week]
|
||||
# By default a week is displayed by the first day of the week – but we'd rather display the last day
|
||||
label = week.next_week
|
||||
|
||||
if total > 0
|
||||
[label, (count.to_f / total * 100).round(2)]
|
||||
else
|
||||
[label, 0]
|
||||
end
|
||||
end.to_h
|
||||
|
||||
{
|
||||
name: legend[rating],
|
||||
data: data
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
def contact_percentage
|
||||
number_of_months = 13
|
||||
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
module Users
|
||||
class FeedbacksController < UserController
|
||||
def create
|
||||
current_user.feedbacks.create!(rating: params[:rating])
|
||||
flash.notice = "Merci de votre retour, si vous souhaitez nous en dire plus, n'hésitez pas à #{helpers.contact_link('nous contacter', type: Helpscout::FormAdapter::TYPE_AMELIORATION)}."
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,21 +0,0 @@
|
|||
# == Schema Information
|
||||
#
|
||||
# Table name: feedbacks
|
||||
#
|
||||
# id :bigint not null, primary key
|
||||
# rating :string not null
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# user_id :bigint
|
||||
#
|
||||
class Feedback < ApplicationRecord
|
||||
belongs_to :user, optional: false
|
||||
|
||||
enum rating: {
|
||||
happy: 'happy',
|
||||
neutral: 'neutral',
|
||||
unhappy: 'unhappy'
|
||||
}
|
||||
|
||||
validates :rating, presence: true
|
||||
end
|
|
@ -44,7 +44,6 @@ class User < ApplicationRecord
|
|||
has_many :dossiers, dependent: :destroy
|
||||
has_many :invites, dependent: :destroy
|
||||
has_many :dossiers_invites, through: :invites, source: :dossier
|
||||
has_many :feedbacks, dependent: :destroy
|
||||
has_many :deleted_dossiers
|
||||
has_one :france_connect_information, dependent: :destroy
|
||||
belongs_to :instructeur, optional: true
|
||||
|
|
|
@ -24,19 +24,6 @@
|
|||
%span.big-number-card-detail
|
||||
#{number_with_delimiter(@dossiers_numbers[:last_30_days_count])} (#{@dossiers_numbers[:evolution]} %) sur les 30 derniers jours
|
||||
|
||||
.stat-card.stat-card-half.pull-left
|
||||
%span.stat-card-title
|
||||
Satisfaction usager
|
||||
|
||||
.chart-container
|
||||
.chart
|
||||
= area_chart @satisfaction_usagers,
|
||||
stacked: true,
|
||||
suffix: ' %',
|
||||
max: 100,
|
||||
library: { plotOptions: { series: { marker: { enabled: true }}}},
|
||||
colors: ["#C31C25", "#F5962A", "#25B177"]
|
||||
|
||||
.stat-card.stat-card-half.pull-left
|
||||
%span.stat-card-title
|
||||
Pourcentage de contact utilisateur
|
||||
|
|
|
@ -23,17 +23,6 @@
|
|||
|
||||
= paginate(deleted_dossiers)
|
||||
|
||||
- if current_user.feedbacks.empty? || current_user.feedbacks.last.created_at < 1.month.ago
|
||||
#user-satisfaction
|
||||
%h3 Que pensez-vous de la facilité d'utilisation de ce service ?
|
||||
.icons
|
||||
= link_to feedback_path(rating: Feedback.ratings.fetch(:unhappy)), data: { remote: true, method: :post } do
|
||||
%span.icon.frown
|
||||
= link_to feedback_path(rating: Feedback.ratings.fetch(:neutral)), data: { remote: true, method: :post } do
|
||||
%span.icon.meh
|
||||
= link_to feedback_path(rating: Feedback.ratings.fetch(:happy)), data: { remote: true, method: :post } do
|
||||
%span.icon.smile
|
||||
|
||||
- else
|
||||
.blank-tab
|
||||
%h2.empty-text Aucun dossier.
|
||||
|
|
|
@ -31,17 +31,6 @@
|
|||
|
||||
= paginate(dossiers)
|
||||
|
||||
- if current_user.feedbacks.empty? || current_user.feedbacks.last.created_at < 1.month.ago
|
||||
#user-satisfaction
|
||||
%h3 Que pensez-vous de la facilité d'utilisation de ce service ?
|
||||
.icons
|
||||
= link_to feedback_path(rating: Feedback.ratings.fetch(:unhappy)), data: { remote: true, method: :post } do
|
||||
%span.icon.frown
|
||||
= link_to feedback_path(rating: Feedback.ratings.fetch(:neutral)), data: { remote: true, method: :post } do
|
||||
%span.icon.meh
|
||||
= link_to feedback_path(rating: Feedback.ratings.fetch(:happy)), data: { remote: true, method: :post } do
|
||||
%span.icon.smile
|
||||
|
||||
- else
|
||||
.blank-tab
|
||||
%h2.empty-text Aucun dossier.
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
try {
|
||||
window.scroll({ top: 0, left: 0, behavior: 'smooth' });
|
||||
} catch(e) {
|
||||
window.scroll(0, 0);
|
||||
}
|
||||
<%= remove_element('#user-satisfaction') %>
|
||||
<%= render_flash %>
|
|
@ -185,60 +185,6 @@ describe StatsController, type: :controller do
|
|||
it { expect(subject).to eq(@expected_hash) }
|
||||
end
|
||||
|
||||
describe "#satisfaction_usagers" do
|
||||
before do
|
||||
# Test the stats on October 2018 – where the 1st, 8th, 15th, 22th and 29th are conveniently Mondays
|
||||
# Current week: 1 negative feedback
|
||||
Timecop.freeze(Time.zone.local(2018, 10, 22, 12, 00)) { create(:feedback, :unhappy) }
|
||||
# Last week: 3 positive, 1 negative
|
||||
Timecop.freeze(Time.zone.local(2018, 10, 21, 12, 00)) { create(:feedback, :unhappy) }
|
||||
Timecop.freeze(Time.zone.local(2018, 10, 19, 12, 00)) { create(:feedback, :happy) }
|
||||
Timecop.freeze(Time.zone.local(2018, 10, 17, 12, 00)) { create(:feedback, :happy) }
|
||||
Timecop.freeze(Time.zone.local(2018, 10, 15, 12, 00)) { create(:feedback, :happy) }
|
||||
# N-2 week: 2 positive, 2 negative
|
||||
Timecop.freeze(Time.zone.local(2018, 10, 14, 12, 00)) { create(:feedback, :unhappy) }
|
||||
Timecop.freeze(Time.zone.local(2018, 10, 12, 12, 00)) { create(:feedback, :happy) }
|
||||
Timecop.freeze(Time.zone.local(2018, 10, 10, 12, 00)) { create(:feedback, :unhappy) }
|
||||
Timecop.freeze(Time.zone.local(2018, 10, 8, 12, 00)) { create(:feedback, :happy) }
|
||||
# N-3 week: 1 positive, 3 negative
|
||||
Timecop.freeze(Time.zone.local(2018, 10, 1, 12, 00)) { create(:feedback, :unhappy) }
|
||||
Timecop.freeze(Time.zone.local(2018, 10, 3, 12, 00)) { create(:feedback, :happy) }
|
||||
Timecop.freeze(Time.zone.local(2018, 10, 5, 12, 00)) { create(:feedback, :unhappy) }
|
||||
Timecop.freeze(Time.zone.local(2018, 10, 7, 12, 00)) { create(:feedback, :unhappy) }
|
||||
end
|
||||
|
||||
subject(:stats) do
|
||||
Timecop.freeze(Time.zone.local(2018, 10, 28, 12, 00)) {
|
||||
StatsController.new.send(:satisfaction_usagers)
|
||||
}
|
||||
end
|
||||
|
||||
it 'returns one set of values for each kind of feedback' do
|
||||
expect(stats.count).to eq 3
|
||||
expect(stats.map { |g| g[:name] }).to contain_exactly('Satisfaits', 'Neutres', 'Mécontents')
|
||||
end
|
||||
|
||||
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[-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[-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
|
||||
unhappy_data = stats.find { |g| g[:name] == 'Mécontents' }[:data]
|
||||
expect(unhappy_data.values).not_to include(100.0)
|
||||
end
|
||||
end
|
||||
|
||||
describe '#avis_usage' do
|
||||
let!(:dossier) { create(:dossier) }
|
||||
let!(:avis_with_dossier) { create(:avis) }
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
FactoryBot.define do
|
||||
factory :feedback do
|
||||
rating { Feedback.ratings.fetch(:happy) }
|
||||
association :user
|
||||
|
||||
trait :happy do
|
||||
rating { Feedback.ratings.fetch(:happy) }
|
||||
end
|
||||
|
||||
trait :neutral do
|
||||
rating { Feedback.ratings.fetch(:neutral) }
|
||||
end
|
||||
|
||||
trait :unhappy do
|
||||
rating { Feedback.ratings.fetch(:unhappy) }
|
||||
end
|
||||
end
|
||||
end
|
|
@ -69,17 +69,4 @@ describe 'users/dossiers/index.html.haml', type: :view do
|
|||
expect(rendered).to have_selector('ul.tabs li.active', count: 1)
|
||||
end
|
||||
end
|
||||
|
||||
context "quand le user n'a aucun feedback" do
|
||||
it "affiche le formulaire de satisfaction" do
|
||||
expect(rendered).to have_selector('#user-satisfaction', text: 'Que pensez-vous de la facilité d\'utilisation de ce service ?')
|
||||
end
|
||||
end
|
||||
|
||||
context "quand le user a un feedback" do
|
||||
let(:user) { create(:user, feedbacks: [build(:feedback)]) }
|
||||
it "n'affiche pas le formulaire de satisfaction" do
|
||||
expect(rendered).to_not have_selector('#user-satisfaction')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue