From 23a7e4db78f3fef16cd3455d2d6aa9be8bbb1a90 Mon Sep 17 00:00:00 2001 From: Kat Date: Tue, 22 Nov 2022 15:16:24 +0000 Subject: [PATCH] refactor --- app/controllers/locations_controller.rb | 3 ++- app/controllers/schemes_controller.rb | 3 ++- app/views/locations/deactivate_confirm.html.erb | 2 +- app/views/schemes/deactivate_confirm.html.erb | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/controllers/locations_controller.rb b/app/controllers/locations_controller.rb index 418d5aa4c..ca2e0b6ac 100644 --- a/app/controllers/locations_controller.rb +++ b/app/controllers/locations_controller.rb @@ -38,7 +38,8 @@ class LocationsController < ApplicationController end def deactivate_confirm - if @location.lettings_logs.filter_by_before_startdate(params[:deactivation_date]).count.zero? + @affected_logs = @location.lettings_logs.filter_by_before_startdate(params[:deactivation_date]) + if @affected_logs.count.zero? deactivate else @deactivation_date = params[:deactivation_date] diff --git a/app/controllers/schemes_controller.rb b/app/controllers/schemes_controller.rb index 8e024c91a..019cc0c75 100644 --- a/app/controllers/schemes_controller.rb +++ b/app/controllers/schemes_controller.rb @@ -39,7 +39,8 @@ class SchemesController < ApplicationController end def deactivate_confirm - if @scheme.lettings_logs.filter_by_before_startdate(params[:deactivation_date]).count.zero? + @affected_logs = @scheme.lettings_logs.filter_by_before_startdate(params[:deactivation_date]) + if @affected_logs.count.zero? deactivate else @deactivation_date = params[:deactivation_date] diff --git a/app/views/locations/deactivate_confirm.html.erb b/app/views/locations/deactivate_confirm.html.erb index f2d722eac..6748af918 100644 --- a/app/views/locations/deactivate_confirm.html.erb +++ b/app/views/locations/deactivate_confirm.html.erb @@ -4,7 +4,7 @@ <% end %>

<%= @location.postcode %> - This change will affect <%= @location.lettings_logs.filter_by_before_startdate(@deactivation_date).count %> logs + This change will affect <%= @affected_logs.count %> logs

<%= govuk_warning_text text: I18n.t("warnings.location.deactivate.review_logs") %> <%= f.hidden_field :confirm, value: true %> diff --git a/app/views/schemes/deactivate_confirm.html.erb b/app/views/schemes/deactivate_confirm.html.erb index b94ff35bd..46ac70190 100644 --- a/app/views/schemes/deactivate_confirm.html.erb +++ b/app/views/schemes/deactivate_confirm.html.erb @@ -6,7 +6,7 @@ <% end %>

<%= @scheme.service_name %> - This change will affect <%= @scheme.lettings_logs.filter_by_before_startdate(@deactivation_date).count %> logs + This change will affect <%= @affected_logs.count %> logs

<%= govuk_warning_text text: I18n.t("warnings.scheme.deactivation.review_logs") %> <%= f.hidden_field :confirm, value: true %>