diff options
author | Jacob Schatz <jschatz1@gmail.com> | 2017-09-22 11:04:28 -0400 |
---|---|---|
committer | Jacob Schatz <jschatz1@gmail.com> | 2017-09-22 11:04:28 -0400 |
commit | 78439bbf3dc7eb2578a5adf18582d7fcf2ace90c (patch) | |
tree | 86768548049bd48e1d410e0ac358bce59ddc0ef8 /app/controllers/projects/issues_controller.rb | |
parent | 2f6f598746db4064c3f046b3bc56bc6ca737b13c (diff) | |
download | gitlab-ce-fast-issue-comments.tar.gz |
Initial partial loading.fast-issue-comments
Diffstat (limited to 'app/controllers/projects/issues_controller.rb')
-rw-r--r-- | app/controllers/projects/issues_controller.rb | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/app/controllers/projects/issues_controller.rb b/app/controllers/projects/issues_controller.rb index 18728d0a1d0..c59de77b0e2 100644 --- a/app/controllers/projects/issues_controller.rb +++ b/app/controllers/projects/issues_controller.rb @@ -97,22 +97,31 @@ class Projects::IssuesController < Projects::ApplicationController def discussions limit = params.has_key?('limit') ? params[:limit] : 3 - notes = @issue.notes - .limit(limit) - .inc_relations_for_view - notes = notes.after_id(params[:after]) if params.has_key?('after') - notes = notes.before_id(params[:before]) if params.has_key?('before') + if params.has_key?('note_id') + note = @issue.notes.includes(:noteable).find(params[:note_id]) + notes = [note] + prepare_notes_for_rendering(notes) + discussions = Discussion.build_collection(notes, @issue) + render json: DiscussionSerializer.new(project: @project, noteable: @issue, current_user: current_user).represent(discussions) + else + notes = @issue.notes + .limit(limit) + .inc_relations_for_view - notes = notes.includes(:noteable) - .fresh - .reject { |n| n.cross_reference_not_visible_for?(current_user) } + notes = notes.after_id(params[:after]) if params.has_key?('after') + notes = notes.before_id(params[:before]) if params.has_key?('before') - prepare_notes_for_rendering(notes) + notes = notes.includes(:noteable) + .fresh + .reject { |n| n.cross_reference_not_visible_for?(current_user) } - discussions = Discussion.build_collection(notes, @issue) + prepare_notes_for_rendering(notes) - render json: DiscussionSerializer.new(project: @project, noteable: @issue, current_user: current_user).represent(discussions) + discussions = Discussion.build_collection(notes, @issue) + + render json: DiscussionSerializer.new(project: @project, noteable: @issue, current_user: current_user).represent(discussions) + end end def create |