Skip to content
Snippets Groups Projects
Verified Commit 952d0508 authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

Pre-fetch all combinations instead of querying for each one

parent a3bc5119
No related branches found
No related tags found
1 merge request!1Resolve "Optimise query count"
...@@ -67,14 +67,16 @@ class Favicon(models.Model): ...@@ -67,14 +67,16 @@ class Favicon(models.Model):
if update: if update:
favicons.delete() favicons.delete()
favicons = FaviconImg.objects.empty() favicons = FaviconImg.objects.empty()
found = []
else: else:
favicons = favicons.all() favicons = favicons.all()
found = [(f.rel, f.size) for f in favicons]
# Check whether favicons are missing # Check whether favicons are missing
new_favicons = [] new_favicons = []
for rel in config: for rel in config:
for size in config[rel]: for size in config[rel]:
if not favicons.filter(rel=rel, size=size): if not (rel, size) in found:
fav = FaviconImg(faviconFK=self, size=size, rel=rel) fav = FaviconImg(faviconFK=self, size=size, rel=rel)
fav.generate_image() fav.generate_image()
new_favicons.append(fav) new_favicons.append(fav)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment