From e5505e1c49f7a9631f1d30b586fc3435c4cd6dad Mon Sep 17 00:00:00 2001 From: Kat Date: Tue, 25 Jul 2023 09:37:09 +0100 Subject: [PATCH] rename scope --- app/controllers/locations_controller.rb | 4 ++-- app/controllers/schemes_controller.rb | 4 ++-- app/models/lettings_log.rb | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/locations_controller.rb b/app/controllers/locations_controller.rb index e55ee10d6..9873fa126 100644 --- a/app/controllers/locations_controller.rb +++ b/app/controllers/locations_controller.rb @@ -170,7 +170,7 @@ class LocationsController < ApplicationController end def deactivate_confirm - @affected_logs = @location.lettings_logs.visible.filter_by_before_startdate(params[:deactivation_date]) + @affected_logs = @location.lettings_logs.visible.after_date(params[:deactivation_date]) if @affected_logs.count.zero? deactivate else @@ -271,7 +271,7 @@ private end def reset_location_and_scheme_for_logs! - logs = @location.lettings_logs.visible.filter_by_before_startdate(params[:deactivation_date].to_time) + logs = @location.lettings_logs.visible.after_date(params[:deactivation_date].to_time) logs.update!(location: nil, scheme: nil, unresolved: true) logs end diff --git a/app/controllers/schemes_controller.rb b/app/controllers/schemes_controller.rb index a433832b5..e026a70b9 100644 --- a/app/controllers/schemes_controller.rb +++ b/app/controllers/schemes_controller.rb @@ -51,7 +51,7 @@ class SchemesController < ApplicationController end def deactivate_confirm - @affected_logs = @scheme.lettings_logs.visible.filter_by_before_startdate(params[:deactivation_date]) + @affected_logs = @scheme.lettings_logs.visible.after_date(params[:deactivation_date]) if @affected_logs.count.zero? deactivate else @@ -335,7 +335,7 @@ private end def reset_location_and_scheme_for_logs! - logs = @scheme.lettings_logs.visible.filter_by_before_startdate(params[:deactivation_date].to_time) + logs = @scheme.lettings_logs.visible.after_date(params[:deactivation_date].to_time) logs.update!(location: nil, scheme: nil, unresolved: true) logs end diff --git a/app/models/lettings_log.rb b/app/models/lettings_log.rb index 0ac0e4bf5..bc4a44a5f 100644 --- a/app/models/lettings_log.rb +++ b/app/models/lettings_log.rb @@ -50,7 +50,7 @@ class LettingsLog < Log .or(filter_by_postcode(param)) .or(filter_by_id(param)) } - scope :filter_by_before_startdate, ->(date) { where("lettings_logs.startdate >= ?", date) } + scope :after_date, ->(date) { where("lettings_logs.startdate >= ?", date) } scope :unresolved, -> { where(unresolved: true) } scope :filter_by_organisation, ->(org, _user = nil) { where(owning_organisation: org).or(where(managing_organisation: org)) }