~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/translations/model/translationtemplatesbuild.py

[rs=buildbot-poller] automatic merge from stable. Revisions: 14329,
        14330, 14331, 14332, 14333 included.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
    implements,
19
19
    )
20
20
 
 
21
from canonical.launchpad.components.decoratedresultset import (
 
22
    DecoratedResultSet,
 
23
    )
21
24
from canonical.launchpad.interfaces.lpstorm import IStore
22
25
from lp.buildmaster.model.buildfarmjob import BuildFarmJobDerived
 
26
from lp.code.model.branch import Branch
 
27
from lp.code.model.branchcollection import GenericBranchCollection
23
28
from lp.code.model.branchjob import (
24
29
    BranchJob,
25
30
    BranchJobType,
26
31
    )
 
32
from lp.registry.model.product import Product
 
33
from lp.services.database.bulk import load_related
27
34
from lp.translations.interfaces.translationtemplatesbuild import (
28
35
    ITranslationTemplatesBuild,
29
36
    ITranslationTemplatesBuildSource,
111
118
        buildfarmjob_ids = [buildfarmjob.id for buildfarmjob in buildfarmjobs]
112
119
        """See `ITranslationTemplatesBuildSource`."""
113
120
        store = cls._getStore(store)
114
 
        return store.find(
 
121
 
 
122
        def eager_load(rows):
 
123
            # Load the related branches, products.
 
124
            branches = load_related(
 
125
                Branch, rows, ['branch_id'])
 
126
            load_related(
 
127
                Product, branches, ['productID'])
 
128
            branch_collection = GenericBranchCollection()
 
129
            # Preload branches cached associated product series and
 
130
            # suite source packages for all the related branches.
 
131
            branch_collection._preloadDataForBranches(branches)
 
132
 
 
133
        resultset = store.find(
115
134
            TranslationTemplatesBuild,
116
135
            TranslationTemplatesBuild.build_farm_job_id.is_in(
117
136
                buildfarmjob_ids))
 
137
        return DecoratedResultSet(resultset, pre_iter_hook=eager_load)
118
138
 
119
139
    @classmethod
120
140
    def findByBranch(cls, branch, store=None):