forked from CGM_Public/pretix_original
create_order_transactions: Make suitable for large datasets
This commit is contained in:
@@ -53,8 +53,17 @@ class Command(BaseCommand):
|
||||
require_approval=False,
|
||||
).prefetch_related(
|
||||
'all_positions', 'all_fees'
|
||||
).order_by(
|
||||
'pk'
|
||||
)
|
||||
for o in tqdm(qs):
|
||||
last_pk = 0
|
||||
with tqdm(total=qs.count()) as pbar:
|
||||
while True:
|
||||
batch = list(qs.filter(pk__gt=last_pk)[:5000])
|
||||
if not batch:
|
||||
break
|
||||
|
||||
for o in batch:
|
||||
if o.last_transaction is None:
|
||||
tn = o.create_transactions(
|
||||
positions=o.all_positions.all(),
|
||||
@@ -79,6 +88,8 @@ class Command(BaseCommand):
|
||||
)
|
||||
if tn:
|
||||
t += 1
|
||||
time.sleep(options.get('slowdown', 0) / 1000)
|
||||
time.sleep(0)
|
||||
pbar.update(1)
|
||||
last_pk = batch[-1].pk
|
||||
|
||||
self.stderr.write(self.style.SUCCESS(f'Created transactions for {t} orders.'))
|
||||
|
||||
Reference in New Issue
Block a user