71
71
from lp.code.model.seriessourcepackagebranch import SeriesSourcePackageBranch
72
from lp.registry.interfaces.person import IPersonSet
72
73
from lp.registry.model.distribution import Distribution
73
74
from lp.registry.model.distroseries import DistroSeries
74
75
from lp.registry.model.person import (
400
401
# limited by the defined collection.
401
402
owned = self.ownedBy(person).getMergeProposals(status)
402
403
reviewing = self.getMergeProposalsForReviewer(person, status)
403
return owned.union(reviewing)
404
resultset = owned.union(reviewing)
406
def do_eager_load(rows):
407
source_branches = load_related(Branch, rows, ['source_branchID'])
408
# Cache person's data (registrants of the proposal and
409
# owners of the source branches).
410
person_ids = set().union(
411
(proposal.registrantID for proposal in rows),
412
(branch.ownerID for branch in source_branches))
413
list(getUtility(IPersonSet).getPrecachedPersonsFromIDs(
414
person_ids, need_validity=True))
415
# Load the source/target branches and preload the data for
417
target_branches = load_related(Branch, rows, ['target_branchID'])
418
self._preloadDataForBranches(target_branches + source_branches)
419
load_related(Product, target_branches, ['productID'])
421
return DecoratedResultSet(resultset, pre_iter_hook=do_eager_load)
405
423
def getMergeProposalsForReviewer(self, reviewer, status=None):
406
424
"""See `IBranchCollection`."""