Skip to content

Commit

Permalink
1593 populate existing asset storage image (#1618)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
jkueloc authored Feb 23, 2022
1 parent d4db5bd commit 65c337d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions concordia/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,21 +353,22 @@ def calculate_difficulty_values(asset_qs=None):
return updated_count


# modify above def for storage_image populate
@celery_app.task
def populate_storage_image_values(asset_qs=None):
"""
For Assets that existed prior to implementing the storage_image ImageField, build
the relative S3 storage key for the asset and update the storage_image value
the relative S3 storage key for the asset and update the storage_image value
"""

# only fetch assest with no storgae image value
asset_qs = (
Asset.objects.filter(storage_image__isnull=True)
.order_by("id")
.prefetch_related("item__project__campaign")[:20000]
.select_related("item__project__campaign")[:20000]
)

logger.debug("Start storage image chunking")

updated_count = 0

# We'll process assets in chunks using an iterator to avoid saving objects
Expand Down

0 comments on commit 65c337d

Please sign in to comment.