Notes API: create_note can make more than 100 SQL queries

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Summary

API::Helpers::NotesHelpers#create_note can make more than 100 SQL requests. This exceeds query limits for acceptable performance.

This is seen when creating command only notes (which may run an arbitrary number of arbitrary commands). It seems to be related to #20824 (closed)

Improvements

We should refactor API::Helpers::NotesHelpers to reduce the number of queries, and remove the call to Gitlab::QueryLimiting.whitelist('https://..') added on line 145.

Involved components

Notes::CreateService, QuickActions::InterpretService, Issuable objects.

Optional: Intended side effects

Increased API performance

Edited by 🤖 GitLab Bot 🤖