~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/code/model/branch.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-08-18 00:32:33 UTC
  • mfrom: (13687.4.9 bug-826692)
  • Revision ID: launchpad@pqm.canonical.com-20110818003233-m7ip8f487fg3ssyu
[r=jtv][bug=826692] Preload related merge proposal data to reduce
        number of queries needed for rendering +activereviews page.

Show diffs side-by-side

added added

removed removed

Lines of Context:
358
358
    @property
359
359
    def landing_candidates(self):
360
360
        """See `IBranch`."""
361
 
        return BranchMergeProposal.select("""
362
 
            BranchMergeProposal.target_branch = %s AND
363
 
            BranchMergeProposal.queue_status NOT IN %s
364
 
            """ % sqlvalues(self, BRANCH_MERGE_PROPOSAL_FINAL_STATES))
 
361
        non_final = tuple(
 
362
            set(BranchMergeProposalStatus.items) -
 
363
            set(BRANCH_MERGE_PROPOSAL_FINAL_STATES))
 
364
        return self.getMergeProposals(status=non_final)
365
365
 
366
366
    @property
367
367
    def dependent_branches(self):
372
372
            """ % sqlvalues(self, BRANCH_MERGE_PROPOSAL_FINAL_STATES))
373
373
 
374
374
    def getMergeProposals(self, status=None, visible_by_user=None,
375
 
                          merged_revnos=None):
 
375
                          merged_revnos=None, eager_load=False):
376
376
        """See `IBranch`."""
377
377
        if not status:
378
378
            status = (
382
382
 
383
383
        collection = getUtility(IAllBranches).visibleByUser(visible_by_user)
384
384
        return collection.getMergeProposals(
385
 
            status, target_branch=self, merged_revnos=merged_revnos)
 
385
            status, target_branch=self, merged_revnos=merged_revnos,
 
386
            eager_load=eager_load)
386
387
 
387
388
    def isBranchMergeable(self, target_branch):
388
389
        """See `IBranch`."""