Skip to content

Commit b398aa0

Browse files
committed
Quick fix to try and resolve the recursive _get_json problem, haven't tested yet
1 parent ca4513d commit b398aa0

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

assembla/api.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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:

assembla/settings.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
API_VERSION = 'v1'
22
API_ROOT_PATH = 'https://api.assembla.com'
3+
4+
MAX_PER_PAGE = 100

0 commit comments

Comments
 (0)