~launchpad-pqm/launchpad/devel

« back to all changes in this revision

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

  • Committer: Launchpad Patch Queue Manager
  • Date: 2012-01-07 17:40:43 UTC
  • mfrom: (14513.3.18 builders-timeout-903827-2)
  • Revision ID: launchpad@pqm.canonical.com-20120107174043-8a8bkggm6n638o0f
[r=jcsackett][bug=903827] Make buildqueue.specific_job and
        builder.currentjob cached properties.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright 2010-2011 Canonical Ltd.  This software is licensed under the
 
1
# Copyright 2010 Canonical Ltd.  This software is licensed under the
2
2
# GNU Affero General Public License version 3 (see the file LICENSE).
3
3
 
4
4
"""`TranslationTemplatesBuild` class."""
117
117
        """See `ITranslationTemplatesBuildSource`."""
118
118
        store = cls._getStore(store)
119
119
 
120
 
        def eager_load(rows):
121
 
            # Load the related branches, products.
122
 
            branches = load_related(
123
 
                Branch, rows, ['branch_id'])
124
 
            load_related(
125
 
                Product, branches, ['productID'])
126
 
            # Preload branches cached associated product series and
127
 
            # suite source packages for all the related branches.
128
 
            GenericBranchCollection.preloadDataForBranches(branches)
129
 
 
130
120
        resultset = store.find(
131
121
            TranslationTemplatesBuild,
132
122
            TranslationTemplatesBuild.build_farm_job_id.is_in(
133
123
                buildfarmjob_ids))
134
 
        return DecoratedResultSet(resultset, pre_iter_hook=eager_load)
 
124
        return DecoratedResultSet(
 
125
            resultset, pre_iter_hook=cls.preloadBuildsData)
 
126
 
 
127
    @classmethod
 
128
    def preloadBuildsData(cls, builds):
 
129
        # Circular imports.
 
130
        from lp.services.librarian.model import LibraryFileAlias
 
131
        # Load the related branches, products.
 
132
        branches = load_related(
 
133
            Branch, builds, ['branch_id'])
 
134
        load_related(
 
135
            Product, branches, ['productID'])
 
136
        # Preload branches cached associated product series and
 
137
        # suite source packages for all the related branches.
 
138
        GenericBranchCollection.preloadDataForBranches(branches)
 
139
        build_farm_jobs = [
 
140
            build.build_farm_job for build in builds]
 
141
        load_related(LibraryFileAlias, build_farm_jobs, ['log_id'])
135
142
 
136
143
    @classmethod
137
144
    def findByBranch(cls, branch, store=None):