mirror of
https://github.com/djohnlewis/stackdump
synced 2024-12-04 23:17:37 +00:00
Reduced the number of database calls for the retrieve_sites view helper.
This commit is contained in:
parent
f4e2c64de7
commit
3b1393d9c2
@ -523,9 +523,12 @@ def retrieve_sites(results):
|
||||
site_keys.add(r['siteKey'])
|
||||
|
||||
# retrieve the site objects from the database
|
||||
site_objects = Site.select(IN(Site.q.key, list(site_keys)))
|
||||
|
||||
# convert results into a dict with site key as the key
|
||||
sites = { }
|
||||
for site_key in site_keys:
|
||||
sites[site_key] = Site.select(Site.q.key == site_key).getOne()
|
||||
for s in site_objects:
|
||||
sites[s.key] = s
|
||||
|
||||
# place site objects into the dict
|
||||
for r in results:
|
||||
|
Loading…
Reference in New Issue
Block a user