Skip to content

Commit

Permalink
improve the notification performance
Browse files Browse the repository at this point in the history
This improvements has two parts:
* Avoid reapplying the visibility check for notifications.
* Merging the constraints rather then having them in a subselect.
  • Loading branch information
ulferts committed Dec 13, 2023
1 parent f9b642f commit 77e127d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
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/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

0 comments on commit 77e127d

Please sign in to comment.