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

View File

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