Skip to content
Snippets Groups Projects

Display Contributor and Author badges on notes

Merged Mycroft Kang requested to merge TaehyeokKang/gitlab:mycroft-note-badge into master
4 unresolved threads
Compare and Show latest version
10 files
+ 61
78
Compare changes
  • Side-by-side
  • Inline
Files
10
@@ -5,7 +5,6 @@ module RendersNotes
@@ -5,7 +5,6 @@ module RendersNotes
def prepare_notes_for_rendering(notes, noteable = nil)
def prepare_notes_for_rendering(notes, noteable = nil)
preload_noteable_for_regular_notes(notes)
preload_noteable_for_regular_notes(notes)
preload_max_access_for_authors(notes, @project)
preload_max_access_for_authors(notes, @project)
preload_first_time_contribution_for_authors(noteable, notes)
preload_author_status(notes)
preload_author_status(notes)
Notes::RenderService.new(current_user).execute(notes)
Notes::RenderService.new(current_user).execute(notes)
@@ -20,6 +19,7 @@ def preload_max_access_for_authors(notes, project)
@@ -20,6 +19,7 @@ def preload_max_access_for_authors(notes, project)
user_ids = notes.map(&:author_id)
user_ids = notes.map(&:author_id)
project.team.max_member_access_for_user_ids(user_ids)
project.team.max_member_access_for_user_ids(user_ids)
 
project.team.contribution_check_for_user_ids(user_ids)
end
end
# rubocop: disable CodeReuse/ActiveRecord
# rubocop: disable CodeReuse/ActiveRecord
@@ -28,12 +28,6 @@ def preload_noteable_for_regular_notes(notes)
@@ -28,12 +28,6 @@ def preload_noteable_for_regular_notes(notes)
end
end
# rubocop: enable CodeReuse/ActiveRecord
# rubocop: enable CodeReuse/ActiveRecord
def preload_first_time_contribution_for_authors(noteable, notes)
return unless noteable.is_a?(Issuable) && noteable.first_contribution?
notes.each {|n| n.specialize_for_first_contribution!(noteable)}
end
# rubocop: disable CodeReuse/ActiveRecord
# rubocop: disable CodeReuse/ActiveRecord
def preload_author_status(notes)
def preload_author_status(notes)
ActiveRecord::Associations::Preloader.new.preload(notes, { author: :status })
ActiveRecord::Associations::Preloader.new.preload(notes, { author: :status })
Loading