Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve the notification performance #14414

Merged
merged 2 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/models/queries/principals/principal_query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ def self.model
end

def default_scope
Principal.not_builtin
Principal.visible(User.current).not_builtin
end
end
4 changes: 3 additions & 1 deletion lib/api/v3/notifications/notifications_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@ def bulk_update_status(attributes)
end
end

# No need to reapply the visibility scope here as this will be done by the used
# NotificationQuery.
get &::API::V3::Utilities::Endpoints::SqlFallbackedIndex
.new(model: Notification, scope: -> { notification_scope })
.new(model: Notification, scope: -> { Notification.where.not(read_ian: nil) })
.mount

post :read_ian do
Expand Down
2 changes: 1 addition & 1 deletion lib/api/v3/principals/principals_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class PrincipalsAPI < ::API::OpenProjectAPI
resource :principals do
get &::API::V3::Utilities::Endpoints::SqlFallbackedIndex
.new(model: Principal,
scope: -> { Principal.visible(current_user).includes(:preference) })
scope: -> { Principal.includes(:preference) })
.mount
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/api/v3/utilities/endpoints/index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def apply_scope_constraint(constraint, result_scope)
else
result_scope
.includes(constraint.includes_values)
.where id: constraint.select(:id)
.merge constraint
end
end
end
Expand Down
Loading