Fix N+1 issues in /api/v3/repos/:namespace/:project/events [RUN ALL RSPEC] [RUN AS-IF-FOSS]
What does this MR do?
The /api/v3/repos/:namespace/:project/events
endpoint was flagged as having N+1 problems #321839 (closed).
The N+1 issues happen when a collection of MergeRequest
s are serialised as API::Github::Entities::PullRequest
entities.
The entity loads these associations:
assignee
author
metrics
-
source_project
These should all be the same but including it avoids relying on the query cache target_project
This MR applies eager loading to avoid N+1 issues during serialization.
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry - [-] Documentation (if required)
-
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides - [-] Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. - [-] Tested in all supported browsers
- [-] Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Related to #321839 (closed)
Edited by Luke Duncalfe