launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #15033
[Merge] lp:~stevenk/launchpad/better-person-preloading-specsearch into lp:launchpad
Steve Kowalik has proposed merging lp:~stevenk/launchpad/better-person-preloading-specsearch into lp:launchpad.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~stevenk/launchpad/better-person-preloading-specsearch/+merge/145316
Make use of pre_iter_hook to preload people, rather than a decorator.
--
https://code.launchpad.net/~stevenk/launchpad/better-person-preloading-specsearch/+merge/145316
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~stevenk/launchpad/better-person-preloading-specsearch into lp:launchpad.
=== modified file 'lib/lp/blueprints/model/specificationsearch.py'
--- lib/lp/blueprints/model/specificationsearch.py 2013-01-29 03:39:16 +0000
+++ lib/lp/blueprints/model/specificationsearch.py 2013-01-29 07:10:30 +0000
@@ -105,15 +105,17 @@
# Set the _known_viewers property for each specification, as well as
# preloading the people involved, if asked.
decorators = []
+ preload_hook = None
if user is not None and not IPersonRoles(user).in_admin:
decorators.append(_make_cache_user_can_view_spec(user))
if prejoin_people:
- decorators.append(_preload_specification_related_people)
+ preload_hook = _preload_specifications_related_people
results = store.using(*tables).find(
Specification, *clauses).order_by(*order).config(limit=quantity)
return DecoratedResultSet(
results,
- lambda row: reduce(lambda task, dec: dec(task), decorators, row))
+ lambda row: reduce(lambda task, dec: dec(task), decorators, row),
+ pre_iter_hook=preload_hook)
def get_specification_active_product_filter(context):
@@ -223,11 +225,14 @@
return cache_user_can_view_spec
-def _preload_specification_related_people(spec):
+def _preload_specifications_related_people(rows):
+ person_ids = set()
+ for spec in rows:
+ person_ids |= set(
+ [spec._assigneeID, spec._approverID, spec._drafterID])
+ person_ids -= set([None])
list(getUtility(IPersonSet).getPrecachedPersonsFromIDs(
- [spec._assigneeID, spec._approverID, spec._drafterID],
- need_validity=True))
- return spec
+ person_ids, need_validity=True))
def get_specification_started_clause():