@@ -82,21 +82,23 @@ def _get_json(self, model, space=None, rel_path=None, extra_params=None, get_all
8282
8383 if response .status_code == 200 : # OK
8484 results = []
85- for json in response .json ():
85+ json_response = response .json ()
86+ for json in json_response :
8687 instance = model (data = json )
8788 instance .api = self
8889 if space :
8990 instance .space = space
9091 results .append (instance )
91- # If `get_all` is True and the length of the current page is divisible by
92- # the maximum limit per page, then we try to fetch the next page
92+ # If it looks like there are more pages to fetch,
93+ # try and fetch the next one
9394 per_page = extra_params .get ('per_page' , None )
9495 if (
9596 get_all
9697 and per_page
97- and len (results )
98- and per_page % len (results ) == 0
98+ and len (json_response )
99+ and per_page == len (json_response )
99100 ):
101+ import pdb ; pdb .set_trace ()
100102 extra_params ['page' ] = extra_params ['page' ] + 1
101103 results = results + self ._get_json (model , space , rel_path , extra_params , get_all = get_all )
102104 return results
@@ -305,7 +307,7 @@ def tickets(self, extra_params=None):
305307
306308 # Default params
307309 params = {
308- 'per_page' : 1000 ,
310+ 'per_page' : settings . MAX_PER_PAGE ,
309311 'report' : 0 , # Report 0 is all tickets
310312 }
311313
@@ -328,7 +330,7 @@ def milestones(self, extra_params=None):
328330
329331 # Default params
330332 params = {
331- 'per_page' : 1000 ,
333+ 'per_page' : settings . MAX_PER_PAGE ,
332334 }
333335
334336 if extra_params :
0 commit comments