summaryrefslogtreecommitdiff
path: root/app/controllers/concerns
diff options
context:
space:
mode:
authormicael.bergeron <micael.bergeron@solutionstlm.com>2017-07-29 11:04:42 -0400
committermicael.bergeron <micael.bergeron@solutionstlm.com>2017-09-06 09:00:57 -0400
commit966b1128d884a318dad4277e23368334fe67e836 (patch)
treec0007ce9697dfe0fe93b52e619e21e8341c35120 /app/controllers/concerns
parent8fe1aa5dbbb41cdefffb7177d9eda44ac8652cc7 (diff)
downloadgitlab-ce-966b1128d884a318dad4277e23368334fe67e836.tar.gz
WIP: refactor the first-contributor to Issuable
this will remove the need make N queries (per-note) at the cost of having to mark notes with an attribute this opens up the possibility for other special roles for notes
Diffstat (limited to 'app/controllers/concerns')
-rw-r--r--app/controllers/concerns/renders_notes.rb9
1 files changed, 8 insertions, 1 deletions
diff --git a/app/controllers/concerns/renders_notes.rb b/app/controllers/concerns/renders_notes.rb
index 41c3114ad1e..cdcfefd90c9 100644
--- a/app/controllers/concerns/renders_notes.rb
+++ b/app/controllers/concerns/renders_notes.rb
@@ -1,7 +1,8 @@
module RendersNotes
- def prepare_notes_for_rendering(notes)
+ def prepare_notes_for_rendering(notes, noteable=nil)
preload_noteable_for_regular_notes(notes)
preload_max_access_for_authors(notes, @project)
+ preload_first_time_contribution_for_authors(noteable, notes) if noteable.is_a?(Issuable)
Banzai::NoteRenderer.render(notes, @project, current_user)
notes
@@ -19,4 +20,10 @@ module RendersNotes
def preload_noteable_for_regular_notes(notes)
ActiveRecord::Associations::Preloader.new.preload(notes.reject(&:for_commit?), :noteable)
end
+
+ def preload_first_time_contribution_for_authors(issuable, notes)
+ return unless issuable.first_contribution?
+ same_author = lambda {|n| n.author_id == issuable.author_id}
+ notes.select(&same_author).each {|note| note.special_role = :first_time_contributor}
+ end
end