Skip to content
Snippets Groups Projects
Commit c31d777c authored by Rémy Coutable's avatar Rémy Coutable
Browse files

Revert changes to how the notes are paginated in the API

parent 3183092c
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -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
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment