From 2a068fb9b0170675e959a03f122c5dbf6b825b24 Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Thu, 15 Apr 2021 16:24:03 +0100 Subject: [PATCH] Remove user feedback buttons --- app/assets/stylesheets/dossier_index.scss | 16 ------ app/controllers/stats_controller.rb | 38 ------------- app/controllers/users/feedbacks_controller.rb | 8 --- app/models/feedback.rb | 21 -------- app/models/user.rb | 1 - app/views/stats/index.html.haml | 13 ----- .../dossiers/_deleted_dossiers_list.html.haml | 11 ---- .../users/dossiers/_dossiers_list.html.haml | 11 ---- app/views/users/feedbacks/create.js.erb | 7 --- spec/controllers/stats_controller_spec.rb | 54 ------------------- spec/factories/feedback.rb | 18 ------- .../users/dossiers/index.html.haml_spec.rb | 13 ----- 12 files changed, 211 deletions(-) delete mode 100644 app/assets/stylesheets/dossier_index.scss delete mode 100644 app/controllers/users/feedbacks_controller.rb delete mode 100644 app/models/feedback.rb delete mode 100644 app/views/users/feedbacks/create.js.erb delete mode 100644 spec/factories/feedback.rb diff --git a/app/assets/stylesheets/dossier_index.scss b/app/assets/stylesheets/dossier_index.scss deleted file mode 100644 index e5a67e1ba..000000000 --- a/app/assets/stylesheets/dossier_index.scss +++ /dev/null @@ -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; - } - } -} diff --git a/app/controllers/stats_controller.rb b/app/controllers/stats_controller.rb index e8d5fa4de..751631dfb 100644 --- a/app/controllers/stats_controller.rb +++ b/app/controllers/stats_controller.rb @@ -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 diff --git a/app/controllers/users/feedbacks_controller.rb b/app/controllers/users/feedbacks_controller.rb deleted file mode 100644 index 6436025bb..000000000 --- a/app/controllers/users/feedbacks_controller.rb +++ /dev/null @@ -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 diff --git a/app/models/feedback.rb b/app/models/feedback.rb deleted file mode 100644 index e0e96b281..000000000 --- a/app/models/feedback.rb +++ /dev/null @@ -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 diff --git a/app/models/user.rb b/app/models/user.rb index d8a15af05..f9f6fa372 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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 diff --git a/app/views/stats/index.html.haml b/app/views/stats/index.html.haml index 4b2032a7c..07792eafb 100644 --- a/app/views/stats/index.html.haml +++ b/app/views/stats/index.html.haml @@ -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 diff --git a/app/views/users/dossiers/_deleted_dossiers_list.html.haml b/app/views/users/dossiers/_deleted_dossiers_list.html.haml index 2b4efe2b3..4b1e039d2 100644 --- a/app/views/users/dossiers/_deleted_dossiers_list.html.haml +++ b/app/views/users/dossiers/_deleted_dossiers_list.html.haml @@ -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. diff --git a/app/views/users/dossiers/_dossiers_list.html.haml b/app/views/users/dossiers/_dossiers_list.html.haml index 35a90aae3..53ea0a2d8 100644 --- a/app/views/users/dossiers/_dossiers_list.html.haml +++ b/app/views/users/dossiers/_dossiers_list.html.haml @@ -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. diff --git a/app/views/users/feedbacks/create.js.erb b/app/views/users/feedbacks/create.js.erb deleted file mode 100644 index 3e7422464..000000000 --- a/app/views/users/feedbacks/create.js.erb +++ /dev/null @@ -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 %> diff --git a/spec/controllers/stats_controller_spec.rb b/spec/controllers/stats_controller_spec.rb index 560ca44ed..ab80cf07e 100644 --- a/spec/controllers/stats_controller_spec.rb +++ b/spec/controllers/stats_controller_spec.rb @@ -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) } diff --git a/spec/factories/feedback.rb b/spec/factories/feedback.rb deleted file mode 100644 index 51b522080..000000000 --- a/spec/factories/feedback.rb +++ /dev/null @@ -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 diff --git a/spec/views/users/dossiers/index.html.haml_spec.rb b/spec/views/users/dossiers/index.html.haml_spec.rb index e3d2514e5..a43e546a9 100644 --- a/spec/views/users/dossiers/index.html.haml_spec.rb +++ b/spec/views/users/dossiers/index.html.haml_spec.rb @@ -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