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
notes_json = { notes: [], last_fetched_at: current_fetched_at }
@notes = notes_finder.execute.inc_relations_for_view.to_a
@notes.reject! { |n| n.cross_reference_not_visible_for?(current_user) }
@notes = prepare_notes_for_rendering(@notes)
notes = notes_finder.execute
.inc_relations_for_view
.reject { |n| n.cross_reference_not_visible_for?(current_user) }
notes = prepare_notes_for_rendering(notes)
notes_json[:notes] =
if noteable.discussions_rendered_on_frontend?
note_serializer.represent(@notes)
note_serializer.represent(notes)
else
@notes.map { |note| note_json(note) }
notes.map { |note| note_json(note) }
end
render json: notes_json
......
......@@ -97,13 +97,17 @@ class Projects::IssuesController < Projects::ApplicationController
end
def discussions
notes = @issue.notes.inc_relations_for_view.includes(:noteable).fresh.to_a
notes.reject! { |n| n.cross_reference_not_visible_for?(current_user) }
notes = @issue.notes
.inc_relations_for_view
.includes(:noteable)
.fresh
.reject { |n| n.cross_reference_not_visible_for?(current_user) }
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
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