Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

improve the notification performance

ulfertseda5f669b075
diff --git a/lib/api/v3/notifications/notifications_api.rb b/lib/api/v3/notifications/notifications_api.rb
index fd87cbd9975..9acaf955b2c 100644
--- a/lib/api/v3/notifications/notifications_api.rb
+++ b/lib/api/v3/notifications/notifications_api.rb
@@ -60,8 +60,10 @@ module API
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
diff --git a/lib/api/v3/utilities/endpoints/index.rb b/lib/api/v3/utilities/endpoints/index.rb
index 4ac995119a8..f01e04b1ba7 100644
--- a/lib/api/v3/utilities/endpoints/index.rb
+++ b/lib/api/v3/utilities/endpoints/index.rb
@@ -164,7 +164,7 @@ module API
else
result_scope
.includes(constraint.includes_values)
- .where id: constraint.select(:id)
+ .merge constraint
end
end
end