Fix N+1 in API::ProjectEvents
As found in !137811 (merged), we have an N+1 for the API::ProjectEvents endpoint.
Steps to reproduce
- Navigate to https://gitlab.com/api/v4/projects/gitlab-org%2Fgitlab-development-kit/events
- Add https://gitlab.com/api/v4/projects/gitlab-org%2Fgitlab-development-kit/events to the performance bar
- Note the repeated
SELECT "projects"."id", ... FROM "projects" WHERE "projects"."id" = 74823 LIMIT 1
SQL queries
Note
This might not be easy to fix because of the polymorphic event.target
Edited by Thong Kuah