Skip to content

Conversation

@RealOrangeOne
Copy link
Member

This way it's incredibly fast, rather than loading them all into memory and iterating. Especially useful for sites with large image libraries.

Untested in its whole, but the theory should be sound.

This way it's incredibly fast, rather than loading them all into memory and iterating. Especially useful for sites with large image libraries.
Copy link
Collaborator

@kevinhowbrook kevinhowbrook left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion jake - I'll have a look at this locally :)

for image in Image.objects.all():
self.update_wagtail_image(image, photos)
for photo, images in zip(photos, self.chunk_images(len(photos))):
images.update(file=f"unsplash-{photo.id}")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't image be a list var here, returned from chunk_images? .update() won't work.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Slicing querysets generally produces querysets, but i'm not sure how that fairs with the mutation that chunk_images is doing.

In my testing it did return lists, although I thought that was something going weird as I had no images locally. If it doesn't work I'll just have to tweak chunk_images, but that shouldn't be too difficult.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants