Skip to content
This repository has been archived by the owner on Nov 27, 2019. It is now read-only.

Stop paging listings after page 99 #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions zoopla/api_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ def _call_api_paged(self, command, args, max_results, result_processor):
There are a few conditions where we need to stop paging
1) We've yielded max_results
2) We've yielded result_count
3) We've reached page number 100 (with a page size of 100)

3 is by design; see http://developer.zoopla.com/forum/read/162309
"""
num_yielded = 0
args['page_size'] = 100
Expand All @@ -92,6 +95,11 @@ def finished():
L.debug("Stop paging, yielded={}, result_count={}".format(
num_yielded, result_count))
return True
elif args['page_number'] == 100:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be >= 100 if for example someone picks a specific page number > 100 rather than simply incrementing.

L.debug("Reached maximum allowable page number. "
"Stop paging, yielded={}, result_count={}".format(
num_yielded, result_count))
return True
else:
return False

Expand Down