~launchpad-pqm/launchpad/devel

« back to all changes in this revision

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

PreloadĀ lfa.

Show diffs side-by-side

added added

removed removed

Lines of Context:
119
119
        """See `ITranslationTemplatesBuildSource`."""
120
120
        store = cls._getStore(store)
121
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
 
            # Preload branches cached associated product series and
129
 
            # suite source packages for all the related branches.
130
 
            GenericBranchCollection.preloadDataForBranches(branches)
131
 
 
132
122
        resultset = store.find(
133
123
            TranslationTemplatesBuild,
134
124
            TranslationTemplatesBuild.build_farm_job_id.is_in(
135
125
                buildfarmjob_ids))
136
 
        return DecoratedResultSet(resultset, pre_iter_hook=eager_load)
 
126
        return DecoratedResultSet(
 
127
            resultset, pre_iter_hook=cls.preloadBuildsData)
 
128
 
 
129
    @classmethod
 
130
    def preloadBuildsData(cls, builds):
 
131
        # Circular imports.
 
132
        from canonical.launchpad.database.librarian import LibraryFileAlias
 
133
        # Load the related branches, products.
 
134
        branches = load_related(
 
135
            Branch, builds, ['branch_id'])
 
136
        load_related(
 
137
            Product, branches, ['productID'])
 
138
        # Preload branches cached associated product series and
 
139
        # suite source packages for all the related branches.
 
140
        GenericBranchCollection.preloadDataForBranches(branches)
 
141
        build_farm_jobs = [
 
142
            build.build_farm_job for build in builds]
 
143
        load_related(LibraryFileAlias, build_farm_jobs, ['log_id'])
137
144
 
138
145
    @classmethod
139
146
    def findByBranch(cls, branch, store=None):