diff options
author | Douwe Maan <douwe@selenight.nl> | 2017-08-18 13:47:50 +0300 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2017-08-18 13:47:50 +0300 |
commit | b7c1b05f30fc45484510f65a5889a89869a7937c (patch) | |
tree | 88e40d1cd3119238bf66e1cce546ea3d902a5eac | |
parent | 91be957cc984ee9c7eb7e8853c963881276e263e (diff) |
No explicit `to_a` or instance variables needed.
-rw-r--r-- | app/controllers/concerns/notes_actions.rb | 12 | ||||
-rw-r--r-- | app/controllers/projects/issues_controller.rb | 12 |
2 files changed, 15 insertions, 9 deletions
diff --git a/app/controllers/concerns/notes_actions.rb b/app/controllers/concerns/notes_actions.rb index c568b401a2f..726838bb284 100644 --- a/app/controllers/concerns/notes_actions.rb +++ b/app/controllers/concerns/notes_actions.rb @@ -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 diff --git a/app/controllers/projects/issues_controller.rb b/app/controllers/projects/issues_controller.rb index e0fb070a841..76bb2b7f811 100644 --- a/app/controllers/projects/issues_controller.rb +++ b/app/controllers/projects/issues_controller.rb @@ -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 |