mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-31 03:59:51 +08:00
Improve activities loading speed [SCI-6345]
This commit is contained in:
parent
9ff71ad651
commit
8f1b201061
2 changed files with 2 additions and 4 deletions
|
@ -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 })
|
||||
|
|
|
@ -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")
|
||||
|
|
Loading…
Reference in a new issue