Support fetching more than 1k changes post 2.8

The update to support the offset rather than sortkey based batching
neglected to account for a query that would need more than 2 batches.

Change-Id: I04ef3243b1fb20cd688af3227fd9998e850fdf9a
This commit is contained in:
James E. Blair 2016-01-29 13:46:24 -08:00
parent dce1155653
commit 74abd8e318
1 changed files with 3 additions and 1 deletions

View File

@ -354,6 +354,7 @@ class SyncProjectTask(Task):
changes = []
sortkey = ''
done = False
offset = 0
while not done:
query = '&'.join(queries)
# We don't actually want to limit to 500, but that's the server-side default, and
@ -371,7 +372,8 @@ class SyncProjectTask(Task):
if '_sortkey' in batch[-1]:
sortkey = '&N=%s' % (batch[-1]['_sortkey'],)
else:
sortkey = '&start=%s' % (len(batch))
offset += len(batch)
sortkey = '&start=%s' % (offset,)
change_ids = [c['id'] for c in changes]
with app.db.getSession() as session:
# Winnow the list of IDs to only the ones in the local DB.