From dde0e692fa9c53885df5f87b9c1168332e1ed983 Mon Sep 17 00:00:00 2001 From: Nat Dean-Lewis Date: Thu, 5 Mar 2026 12:38:58 +0000 Subject: [PATCH] CLDC-4226: use unscoped in block form --- app/models/log.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/log.rb b/app/models/log.rb index 415d5cd2f..00a178e2b 100644 --- a/app/models/log.rb +++ b/app/models/log.rb @@ -52,8 +52,8 @@ class Log < ApplicationRecord scope :imported_2023, -> { imported.filter_by_year(2023) } # TODO: CLDC-4273: use .union in filter_by_organisation rather than raw SQL scope :filter_by_organisation, lambda { |orgs, _user = nil| - owned = where(owning_organisation: orgs).select(:id) - managed = where(managing_organisation: orgs).select(:id) + owned = unscoped { where(owning_organisation: orgs).select(:id) } + managed = unscoped { where(managing_organisation: orgs).select(:id) } where("#{table_name}.id = ANY(ARRAY(#{owned.to_sql} UNION #{managed.to_sql}))") }