Improve performance of filtering notes in NotesController
Reduces the number of queries needed to redact notes to which the user does not have access. Also includes an N+1 query test as a guard against future issues.
This is a follow-up from https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/14327#note_40976854.