Commit Graph

7 Commits

Author SHA1 Message Date
GitLab Bot 4c5468b408 Add latest changes from gitlab-org/gitlab@master 2020-06-24 15:08:50 +00:00
GitLab Bot 0ba3a054d2 Add latest changes from gitlab-org/gitlab@master 2020-01-10 09:07:49 +00:00
Sean McGivern b26e5546c3 Only load issue notes once when getting related MRs
As we always call both methods from the controller - and elsewhere we call the
more general method - and one uses all notes and the other uses system notes,
then we should just load the notes and their authors once, and filter on the
Ruby side.
2018-08-21 12:58:32 +01:00
Sean McGivern fd072f7df7 Fix CI pipelines N+1 in Issues::ReferencedMergeRequestsService
Whether the preloading belongs in the service or the controller is arguable,
here. As the service is only used for one controller action, it seems reasonable
to put it in the service, but that is not a definitive answer.

Adding the preloads for MR project routes here doesn't seem to work, perhaps
because of https://github.com/rails/rails/issues/32140.
2018-08-21 12:45:05 +01:00
Sean McGivern 2017c5c62a Fix routes N+1 in Issues::ReferencedMergeRequestsService#execute
Sorting here needs the project routes to be loaded, including the namespace
routes.
2018-08-21 12:40:44 +01:00
Sean McGivern 22d8fbacaf Fix authors N+1 in Issues::ReferencedMergeRequestsService
`#referenced_merge_requests` preloaded too many associations. Award emoji, for
instance, are completely unnecessary here.

`#closed_by_merge_requests` had the opposite problem: `#all_references` needs
each item's author, and these weren't preloaded.
2018-08-21 12:40:44 +01:00
Sean McGivern c73da6c1e7 Move Issue#{referenced,closed_by}_merge_requests to service
These methods don't really need to be on the Issue model. Issue#related_branches
can also be moved to a service, but we can do that in a separate commit.

This commit does not change any behaviour; it just moves code around, renames
the service, and refactors the specs.
2018-08-21 12:40:44 +01:00