diff --git a/CHANGELOG b/CHANGELOG index 25936eb1e1ddb1ac98e7cd90d65b87b98c935119..511ecf5d07648fb7a4f07b4472af097ed62ccd54 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -31,6 +31,7 @@ v 7.10.0 (unreleased) - Replace commits calendar with faster contribution calendar that includes issues and merge requests - Add inifinite scroll to user page activity - Don't show commit comment button when user is not signed in. + - Don't include system notes in issue/MR comment count. v 7.9.0 - Send EmailsOnPush email when branch or tag is created or deleted. diff --git a/app/models/note.rb b/app/models/note.rb index 27b583a869abd25ea2cbc110f792a74a0123ad1c..e86160e7cd9ebdb0897d2df1b62bf0f1577df980 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -48,6 +48,7 @@ class Note < ActiveRecord::Base scope :inline, ->{ where("line_code IS NOT NULL") } scope :not_inline, ->{ where(line_code: [nil, '']) } scope :system, ->{ where(system: true) } + scope :user, ->{ where(system: false) } scope :common, ->{ where(noteable_type: ["", nil]) } scope :fresh, ->{ order(created_at: :asc, id: :asc) } scope :inc_author_project, ->{ includes(:project, :author) } diff --git a/app/views/projects/commits/_commit.html.haml b/app/views/projects/commits/_commit.html.haml index 4c853f577e956fe879a131a6e9925fd7e57b9722..c6026f968045358927506784a4cb8bf0812f5ee4 100644 --- a/app/views/projects/commits/_commit.html.haml +++ b/app/views/projects/commits/_commit.html.haml @@ -13,7 +13,7 @@ - note_count = @note_counts.fetch(commit.id, 0) - else - notes = project.notes.for_commit_id(commit.id) - - note_count = notes.count + - note_count = notes.user.count - if note_count > 0 %span.light diff --git a/app/views/projects/issues/_issue.html.haml b/app/views/projects/issues/_issue.html.haml index 7b06fe728827ef1dbfa021187bbc5d12df3b4ce6..998e74d12cf8539b7fd7a5e9597da79de5c04cb5 100644 --- a/app/views/projects/issues/_issue.html.haml +++ b/app/views/projects/issues/_issue.html.haml @@ -10,11 +10,12 @@ - if issue.closed? %span CLOSED - - if issue.notes.any? + - note_count = issue.notes.user.count + - if note_count > 0 %span %i.fa.fa-comments - = issue.notes.count + = note_count .issue-info = link_to "##{issue.iid}", issue_path(issue), class: "light" diff --git a/app/views/projects/merge_requests/_merge_request.html.haml b/app/views/projects/merge_requests/_merge_request.html.haml index ecbff722b421b7160be7713640170c88f70d1bf4..4f30d1e69f79fd0525bfb4a290bffc15ad19f011 100644 --- a/app/views/projects/merge_requests/_merge_request.html.haml +++ b/app/views/projects/merge_requests/_merge_request.html.haml @@ -16,11 +16,12 @@ %span.label-branch< %i.fa.fa-code-fork %span= merge_request.target_branch - - if merge_request.notes.any? + - note_count = merge_request.mr_and_commit_notes.user.count + - if note_count > 0 %span %i.fa.fa-comments - = merge_request.mr_and_commit_notes.count + = note_count .merge-request-info = link_to "##{merge_request.iid}", merge_request_path(merge_request), class: "light" - if merge_request.assignee diff --git a/app/views/projects/merge_requests/_show.html.haml b/app/views/projects/merge_requests/_show.html.haml index ca4ceecb225945e07887e5af8fc9f8f92da4a30a..a74aede4e6bacba98678caafce79a91a7ddf2009 100644 --- a/app/views/projects/merge_requests/_show.html.haml +++ b/app/views/projects/merge_requests/_show.html.haml @@ -40,7 +40,7 @@ = link_to merge_request_path(@merge_request) do %i.fa.fa-comments Discussion - %span.badge= @merge_request.mr_and_commit_notes.count + %span.badge= @merge_request.mr_and_commit_notes.user.count %li.commits-tab{data: {action: 'commits'}} = link_to merge_request_path(@merge_request), title: 'Commits' do %i.fa.fa-history diff --git a/lib/gitlab/project_search_results.rb b/lib/gitlab/project_search_results.rb index 8b85f3da83fd19d4198403ee0977b98cfab469e7..0dab7bcfa4d0c9af1081042fdd3121bdb924b779 100644 --- a/lib/gitlab/project_search_results.rb +++ b/lib/gitlab/project_search_results.rb @@ -67,7 +67,7 @@ module Gitlab end def notes - Note.where(project_id: limit_project_ids).search(query).order('updated_at DESC') + Note.where(project_id: limit_project_ids).user.search(query).order('updated_at DESC') end def limit_project_ids