update
This commit is contained in:
@@ -75,6 +75,21 @@ def since(conn, collection, seq):
|
||||
return [json.loads(r["data"]) for r in rows]
|
||||
|
||||
|
||||
def since_paged(conn, collection, seq, max_bytes):
|
||||
"""Wie since, aber höchstens max_bytes Daten. Gibt (Einträge, letzter seq, mehr da) zurück."""
|
||||
rows = conn.execute(
|
||||
"SELECT data, seq FROM items WHERE collection = ? AND seq > ? ORDER BY seq", (collection, seq)
|
||||
)
|
||||
items, size, last = [], 0, seq
|
||||
for r in rows:
|
||||
if items and size + len(r["data"]) > max_bytes:
|
||||
return items, last, True
|
||||
items.append(json.loads(r["data"]))
|
||||
size += len(r["data"])
|
||||
last = r["seq"]
|
||||
return items, last, False
|
||||
|
||||
|
||||
def alive(conn, collection):
|
||||
rows = conn.execute(
|
||||
"SELECT data FROM items WHERE collection = ? AND deleted = 0 ORDER BY id", (collection,)
|
||||
|
||||
Reference in New Issue
Block a user