Network::Graph#collect_notes has too much knowledge of the Note model

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

Per https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/4360/diffs#a77b510d8b481001415ce6c5305a71bce8404fa1_28_33, this method has way, way too much knowledge of the Note model:

      @project
        .notes
        .where('noteable_type = ?', 'Commit')
        .group('notes.commit_id')
        .select('notes.commit_id, count(notes.id) as note_count')
        .each do |item|
          h[item.commit_id] = item.note_count.to_i
        end
  • We should probably have named scopes for for_commit, for_issue, etc. on Note.
  • The group and select calls should probably be contained in a method on Note
Edited by 🤖 GitLab Bot 🤖