1
0
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:
Samuel Lai 2012-02-12 16:51:14 +11:00
parent f4e2c64de7
commit 3b1393d9c2

View File

@ -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: