From ddd4d3a2c549aca17cc58f0a337dac113b49859c Mon Sep 17 00:00:00 2001 From: Kat Date: Tue, 5 Mar 2024 08:26:00 +0000 Subject: [PATCH] Refactor query --- app/policies/location_policy.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/policies/location_policy.rb b/app/policies/location_policy.rb index 9c3c4882b..436b961c6 100644 --- a/app/policies/location_policy.rb +++ b/app/policies/location_policy.rb @@ -89,8 +89,7 @@ private def has_any_logs_in_editable_collection_period editable_from_date = FormHandler.instance.earliest_open_for_editing_collection_start_date - editable_logs = LettingsLog.where(location_id: location.id).after_date(editable_from_date) - LettingsLog.where(location_id: location.id, startdate: nil).any? || editable_logs.any? + LettingsLog.where(location_id: location.id).after_date(editable_from_date).or(LettingsLog.where(startdate: nil, location_id: location.id)).any? end end