Fix tags API pagination and add a test

This commit is contained in:
Joseph Schorr 2016-10-03 21:10:39 +03:00
parent 671dc73b82
commit f72cb1d2ba
2 changed files with 74 additions and 33 deletions

View file

@ -55,8 +55,9 @@ def paginate(limit_kwarg_name='limit', offset_kwarg_name='offset',
offset = page_info.get('offset', 0)
def callback(num_results, response):
if num_results <= limit:
if num_results < limit:
return
next_page_token = encrypt_page_token({'offset': limit + offset})
link = get_app_url() + url_for(request.endpoint, **request.view_args)
link += '?%s; rel="next"' % urlencode({'n': limit, 'next_page': next_page_token})