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.
86 jobs for sh-improve-perf-notes-actions in 72 minutes and 41 seconds (queued for 7 seconds)