Commit b7c1b05f authored by Douwe Maan's avatar Douwe Maan

No explicit `to_a` or instance variables needed.

parent 91be957c
...@@ -13,15 +13,17 @@ module NotesActions ...@@ -13,15 +13,17 @@ module NotesActions
notes_json = { notes: [], last_fetched_at: current_fetched_at } notes_json = { notes: [], last_fetched_at: current_fetched_at }
@notes = notes_finder.execute.inc_relations_for_view.to_a notes = notes_finder.execute
@notes.reject! { |n| n.cross_reference_not_visible_for?(current_user) } .inc_relations_for_view
@notes = prepare_notes_for_rendering(@notes) .reject { |n| n.cross_reference_not_visible_for?(current_user) }
notes = prepare_notes_for_rendering(notes)
notes_json[:notes] = notes_json[:notes] =
if noteable.discussions_rendered_on_frontend? if noteable.discussions_rendered_on_frontend?
note_serializer.represent(@notes) note_serializer.represent(notes)
else else
@notes.map { |note| note_json(note) } notes.map { |note| note_json(note) }
end end
render json: notes_json render json: notes_json
......
...@@ -97,13 +97,17 @@ class Projects::IssuesController < Projects::ApplicationController ...@@ -97,13 +97,17 @@ class Projects::IssuesController < Projects::ApplicationController
end end
def discussions def discussions
notes = @issue.notes.inc_relations_for_view.includes(:noteable).fresh.to_a notes = @issue.notes
notes.reject! { |n| n.cross_reference_not_visible_for?(current_user) } .inc_relations_for_view
.includes(:noteable)
.fresh
.reject { |n| n.cross_reference_not_visible_for?(current_user) }
prepare_notes_for_rendering(notes) prepare_notes_for_rendering(notes)
@discussions = Discussion.build_collection(notes, @issue) discussions = Discussion.build_collection(notes, @issue)
render json: DiscussionSerializer.new(project: @project, noteable: @issue, current_user: current_user).represent(@discussions) render json: DiscussionSerializer.new(project: @project, noteable: @issue, current_user: current_user).represent(discussions)
end end
def create def create
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment