diff options
author | Rémy Coutable <remy@rymai.me> | 2016-01-14 12:08:44 +0100 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2016-01-14 12:10:27 +0100 |
commit | 3183092ca94b14d6e61f5e8ba51069554646baf8 (patch) | |
tree | 05e7d558cbf946710db76f1597e05e1ff9100904 /lib/api/notes.rb | |
parent | 9f8c38bdac3d6f532b50ecab1d769652ffb5acc3 (diff) | |
download | gitlab-ce-add-pagination-headers-to-api.tar.gz |
Add pagination headers to already paginated API resourcesadd-pagination-headers-to-api
Diffstat (limited to 'lib/api/notes.rb')
-rw-r--r-- | lib/api/notes.rb | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/lib/api/notes.rb b/lib/api/notes.rb index 174473f5371..ebd9e97148c 100644 --- a/lib/api/notes.rb +++ b/lib/api/notes.rb @@ -22,17 +22,11 @@ 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 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. + # by the current user. 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). + @noteable.notes. reject { |n| n.cross_reference_not_visible_for?(current_user) } - present notes, with: Entities::Note + present paginate(Kaminari.paginate_array(notes)), with: Entities::Note end # Get a single +noteable+ note |