Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update images in DB #10

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

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