diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-25 12:08:11 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-25 12:08:11 +0300 |
commit | 5064bf8c5647d4c4430cbb4d097cf1592416de29 (patch) | |
tree | d051bf2abe2cc7061b3a7facb6669a56ccb9cf54 /lib/api/discussions.rb | |
parent | 9c83aadd2604e7e6cb1f84683f951e6b12872618 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/api/discussions.rb')
-rw-r--r-- | lib/api/discussions.rb | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/lib/api/discussions.rb b/lib/api/discussions.rb index a1cec148aeb..8ff275a3a1b 100644 --- a/lib/api/discussions.rb +++ b/lib/api/discussions.rb @@ -28,10 +28,10 @@ module API get ":id/#{noteables_path}/:noteable_id/discussions" do noteable = find_noteable(noteable_type, params[:noteable_id]) - notes = readable_discussion_notes(noteable) - discussions = Kaminari.paginate_array(Discussion.build_collection(notes, noteable)) + discussion_ids = paginate(noteable.discussion_ids_relation) + notes = readable_discussion_notes(noteable, discussion_ids) - present paginate(discussions), with: Entities::Discussion + present Discussion.build_collection(notes, noteable), with: Entities::Discussion end desc "Get a single #{noteable_type.to_s.downcase} discussion" do @@ -221,10 +221,9 @@ module API helpers do # rubocop: disable CodeReuse/ActiveRecord - def readable_discussion_notes(noteable, discussion_id = nil) + def readable_discussion_notes(noteable, discussion_ids) notes = noteable.notes - notes = notes.where(discussion_id: discussion_id) if discussion_id - notes = notes + .where(discussion_id: discussion_ids) .inc_relations_for_view .includes(:noteable) .fresh |