Optimize issuable APIs interaction with notes
Addressing concerns on the issues API performance on #17960 (closed), there currently are a couple of n+1 or pseudo n+1 queries (see the commit messages for details) when dealing with notes
. This MR fixes those problems.