summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2016-01-14 14:20:21 +0100
committerRémy Coutable <remy@rymai.me>2016-01-14 14:20:21 +0100
commitc31d777c8f24029d7e11dd1e78eddf0c0b6e6f01 (patch)
tree7db6d55f40cd186a8ffc0cf38fb89a5c740a6539
parent3183092ca94b14d6e61f5e8ba51069554646baf8 (diff)
downloadgitlab-ce-c31d777c8f24029d7e11dd1e78eddf0c0b6e6f01.tar.gz
Revert changes to how the notes are paginated in the API
-rw-r--r--lib/api/notes.rb12
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/api/notes.rb b/lib/api/notes.rb
index ebd9e97148c..174473f5371 100644
--- a/lib/api/notes.rb
+++ b/lib/api/notes.rb
@@ -22,11 +22,17 @@ module API
@noteable = user_project.send(:"#{noteables_str}").find(params[:"#{noteable_id_str}"])
# We exclude notes that are cross-references and that cannot be viewed
- # by the current user.
+ # by the current user. By doing this exclusion at this level and not
+ # at the DB query level (which we cannot in that case), the current
+ # page can have less elements than :per_page even if
+ # there's more than one page.
notes =
- @noteable.notes.
+ # paginate() only works with a relation. This could lead to a
+ # mismatch between the pagination headers info and the actual notes
+ # array returned, but this is really a edge-case.
+ paginate(@noteable.notes).
reject { |n| n.cross_reference_not_visible_for?(current_user) }
- present paginate(Kaminari.paginate_array(notes)), with: Entities::Note
+ present notes, with: Entities::Note
end
# Get a single +noteable+ note