update projects list offset calculation

This commit is contained in:
Sergiy Litvinchuk 2016-05-06 11:48:11 +03:00
parent cd5f77dd2c
commit 7141283274
1 changed files with 2 additions and 4 deletions

View File

@ -21,18 +21,16 @@ class RedmineClient(object):
def get_projects(self):
limit = 100
offset = 0
projects = []
def get_response(limit, offset):
return self.request('GET', '/projects.json?limit=%s&offset=%s' % (limit, offset))
response = get_response(limit, offset)
response = get_response(limit, 0)
while len(response['projects']):
projects.extend(response['projects'])
offset += limit
response = get_response(limit, offset)
response = get_response(limit, response['offset'] + response['limit'])
return {'projects': projects}