Skip to content

Commit

Permalink
Change ordering of update in product discounted price task (saleor#12690
Browse files Browse the repository at this point in the history
)
  • Loading branch information
tomaszszymanski129 authored May 10, 2023
1 parent 4cbc8e3 commit 2bfbb10
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions saleor/product/utils/variant_prices.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,16 @@ def _products_in_batches(products_qs):
# Results in memory usage of ~40MB for 500 products
BATCH_SIZE = 500

first_batch = True

while True:
filter_args = {}
if not first_batch:
filter_args = {"pk__lt": start_pk}
first_batch = False
products = list(
products_qs.order_by("pk")
.filter(pk__gt=start_pk)
products_qs.order_by("-pk")
.filter(**filter_args)
.prefetch_related("channel_listings", "collections")[:BATCH_SIZE]
)
if not products:
Expand Down

0 comments on commit 2bfbb10

Please sign in to comment.