From 4823bf2f109bb5307b97a44dfbcf97389c155285 Mon Sep 17 00:00:00 2001 From: Jennifer Kuenning <72825410+jkueloc@users.noreply.github.com> Date: Thu, 24 Feb 2022 08:56:10 -0500 Subject: [PATCH] 1593 populate existing asset storage image (#1619) * black and flake 8 updates * add ordering on qs * black changes * back changes * fix bad conflict resolution change * cleanup comments - switch back to select related * increase limit and chunk since 20k chunked 2k ran in a minute --- concordia/tasks.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/concordia/tasks.py b/concordia/tasks.py index bb710ddde..7714877df 100644 --- a/concordia/tasks.py +++ b/concordia/tasks.py @@ -364,7 +364,7 @@ def populate_storage_image_values(asset_qs=None): asset_qs = ( Asset.objects.filter(storage_image__isnull=True) .order_by("id") - .select_related("item__project__campaign")[:20000] + .select_related("item__project__campaign")[:50000] ) logger.debug("Start storage image chunking") @@ -374,7 +374,7 @@ def populate_storage_image_values(asset_qs=None): # We'll process assets in chunks using an iterator to avoid saving objects # which will never be used again in memory. We will build the S3 relative key for # each existing asset and pass them to bulk_update() to be saved in a single query. - for asset_chunk in chunked(asset_qs.iterator(), 2000): + for asset_chunk in chunked(asset_qs.iterator(), 3000): for asset in asset_chunk: asset.storage_image = "/".join(