mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-23 01:51:08 +00:00
Update preview image generation to only query ids
Previously we were querying the full book objects just to get a list of id's, which is much slower and also takes a lot more memory, which can cause the process to be killed on memory-limited machines with a large number of books. Instead, since we're just dispatching jobs here, we can just ask for the id's, which is faster and much more practical memory-wise. The map is a little annoying, I didn't see a way to directly get just a list of the value of one field, so we have to get a list of dictionairies with one key and then pull that key out. Whatevs.
This commit is contained in:
parent
7905be7de2
commit
482005f304
1 changed files with 4 additions and 4 deletions
|
@ -56,12 +56,12 @@ class Command(BaseCommand):
|
|||
self.stdout.write(" OK 🖼")
|
||||
|
||||
# Books
|
||||
books = models.Book.objects.select_subclasses().filter()
|
||||
book_ids = [values["id"] for values in models.Book.objects.select_subclasses().filter().values('id')]
|
||||
self.stdout.write(
|
||||
" → Book preview images ({}): ".format(len(books)), ending=""
|
||||
" → Book preview images ({}): ".format(len(book_ids)), ending=""
|
||||
)
|
||||
for book in books:
|
||||
preview_images.generate_edition_preview_image_task.delay(book.id)
|
||||
for book_id in book_ids:
|
||||
preview_images.generate_edition_preview_image_task.delay(book_id)
|
||||
self.stdout.write(".", ending="")
|
||||
self.stdout.write(" OK 🖼")
|
||||
|
||||
|
|
Loading…
Reference in a new issue