···220220 if limit < 1 or limit > 100:
221221 raise web.HTTPBadRequest(text="limit out of range")
222222 reverse = request.query.get("reverse") == "true"
223223- cursor = request.query.get("cursor", "" if reverse else "\xff")
223223+ cursor = request.query.get("cursor", "")
224224+ if not reverse and not cursor:
225225+ cursor = "\xff" # compares greater than all valid rkeys
224226 did_or_handle = request.query["repo"]
225227 collection = request.query["collection"]
226228 records = []
+3-3
src/millipds/atproto_sync.py
···190190 limit = int(request.query.get("limit", 500))
191191 if limit < 1 or limit > 1000:
192192 raise web.HTTPBadRequest(text="limit out of range")
193193- cursor = int(request.query.get("cursor", 0))
193193+ cursor = int(request.query.get("cursor") or 0)
194194195195 cids = []
196196 for id_, cid in get_db(request).con.execute(
···246246 await ws.prepare(request) # TODO: should this be outside of try?
247247248248 last_sent_seq = None
249249- if "cursor" in request.query:
249249+ if cursor_str := request.query.get("cursor"):
250250 # TODO: try to limit number of concurrent backfillers? (it's more expensive than livetailing)
251251- cursor = int(request.query["cursor"])
251251+ cursor = int(cursor_str)
252252 db = get_db(request)
253253 while True:
254254 # we read one at a time to force gaps between reads - could be a perf win to read in small batches
+1
src/millipds/database.py
···150150 ) STRICT
151151 """
152152 )
153153+ # TODO: index on timestamp for efficient purging of old events.
153154154155 # repo storage stuff
155156 self.con.execute(