diff --git a/app/models/concerns/assignable.rb b/app/models/concerns/assignable.rb index 022e3a797..78ebbed74 100644 --- a/app/models/concerns/assignable.rb +++ b/app/models/concerns/assignable.rb @@ -10,8 +10,6 @@ module Assignable has_many :user_assignments, as: :assignable, dependent: :destroy - default_scope { includes(user_assignments: :user_role).distinct } - scope :readable_by_user, lambda { |user| joins(user_assignments: :user_role) .where(user_assignments: { user: user }) diff --git a/app/services/activities_service.rb b/app/services/activities_service.rb index f46c95a9d..f9f19264f 100644 --- a/app/services/activities_service.rb +++ b/app/services/activities_service.rb @@ -5,9 +5,9 @@ class ActivitiesService # Create condition for view permissions checking first visible_teams = user.teams.where(id: teams) visible_projects = Project.viewable_by_user(user, visible_teams) - visible_by_teams = Activity.where(project: nil, team_id: visible_teams.pluck(:id)) + visible_by_teams = Activity.where(project: nil, team_id: visible_teams.select(:id)) .order(created_at: :desc) - visible_by_projects = Activity.where(project_id: visible_projects.pluck(:id)) + visible_by_projects = Activity.where(project_id: visible_projects.select(:id)) .order(created_at: :desc) query = Activity.from("((#{visible_by_teams.to_sql}) UNION ALL (#{visible_by_projects.to_sql})) AS activities")