Container.delete() should split into chunks by default
Created by: Quazgar
This is prevent over-long URIs.
Imported comments:
By Quazgar on 2020-09-29T14:00:48.345Z
Implementation code snippet:
max_id = 1157 ### Take min/max of container instead
while True:
deletable = db.execute_query(
"FIND Entity with ID > {} AND WHICH IS NOT REFERENCED".format(max_id)) ### Use for intersection with Container.
if not deletable:
break
chunk_size = 100
for i in range(0, int(len(deletable)/chunk_size + 1)):
chunk = db.Container()
for j in range(i*chunk_size, min(len(deletable), (i+1)*chunk_size)):
chunk.append(deletable[j])
print(i, i*chunk_size, min(len(deletable), (i+1)*chunk_size))
print(len(chunk))
chunk.delete()
deletable = db.execute_query("FIND Entity with ID > {}".format(max_id))
if deletable:
deletable.delete()