From c4b3b104291bbd238091312ebe7c3ab65a440489 Mon Sep 17 00:00:00 2001 From: Martin Artnik Date: Thu, 12 Sep 2024 16:24:46 +0200 Subject: [PATCH] Fix shareable scope [SCI-10865] --- app/models/concerns/shareable.rb | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/app/models/concerns/shareable.rb b/app/models/concerns/shareable.rb index 95ba20437..6f157766e 100644 --- a/app/models/concerns/shareable.rb +++ b/app/models/concerns/shareable.rb @@ -30,19 +30,17 @@ module Shareable readable = readable_by_user(user).left_outer_joins(:team_shared_objects) readable .where(team: teams) - .or(readable.where(team_shared_objects: { team: teams })) - .or(readable - .where( - if column_names.include?('permission_level') - { - permission_level: [ - Extends::SHARED_OBJECTS_PERMISSION_LEVELS[:shared_read], - Extends::SHARED_OBJECTS_PERMISSION_LEVELS[:shared_write] - ] - } - else - {} - end + .or(where(team_shared_objects: { team: teams })) + .or(where(if column_names.include?('permission_level') + { + permission_level: [ + Extends::SHARED_OBJECTS_PERMISSION_LEVELS[:shared_read], + Extends::SHARED_OBJECTS_PERMISSION_LEVELS[:shared_write] + ] + } + else + {} + end ).where.not(team: teams)) .distinct }