Commit graph

5 commits

Author SHA1 Message Date
Yorick Peterse
2039c8280d
Disable existing offenses for the CodeReuse cops
This whitelists all existing offenses for the various CodeReuse cops, of
which most are triggered by the CodeReuse/ActiveRecord cop.
2018-09-11 17:32:00 +02: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
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