Eliminate many Gitaly calls in discussions API
Previously, the API to retrieve discussions from merge requests often generated hundreds of Gitaly calls to determine whether a system note should be shown to the user. It did this by:
- Rendering the Markdown
- Extracting cross-references from the Markdown
- For cross-references that were commits, a Gitaly FindCommit RPC would be issued to validate that the commit exists.
The last step is unnecessary because we don't need to display a commit if the user doesn't have access to the project in the first place.
RendersNotes#prepare_notes_for_rendering
is already used in
MergeRequestsController
, which is why we don't see N+1 Gitaly calls
there. We use it here to optimize the note redaction process.
Edited by Stan Hu