~launchpad-pqm/launchpad/devel

« back to all changes in this revision

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

  • Committer: Launchpad Patch Queue Manager
  • Date: 2012-01-02 15:48:28 UTC
  • mfrom: (14513.2.4 builders-timeout-903827)
  • Revision ID: launchpad@pqm.canonical.com-20120102154828-r4echs7u11g99u8b
[r=adeuring][bug=903827] Cache objects prior to displaying builders'
        homepage.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright 2010 Canonical Ltd. This software is licensed under the
 
1
# Copyright 2010-2011 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
__metaclass__ = type
36
36
    BranchJobType,
37
37
    )
38
38
from lp.services.config import config
 
39
from lp.services.database.bulk import load_related
39
40
from lp.services.database.lpstorm import (
40
41
    IMasterStore,
41
42
    IStore,
226
227
            return cls(branch_job)
227
228
 
228
229
    @classmethod
 
230
    def getByJobs(cls, jobs):
 
231
        """See `IBuildFarmJob`.
 
232
 
 
233
        Overridden here to search via a BranchJob, rather than a Job.
 
234
        """
 
235
        store = IStore(BranchJob)
 
236
        job_ids = [job.id for job in jobs]
 
237
        branch_jobs = store.find(
 
238
            BranchJob, BranchJob.jobID.is_in(job_ids))
 
239
        return [cls(branch_job) for branch_job in branch_jobs]
 
240
 
 
241
    @classmethod
 
242
    def preloadJobsData(cls, jobs):
 
243
        # Circular imports.
 
244
        from lp.code.model.branch import Branch
 
245
        from lp.registry.model.product import Product
 
246
        from lp.code.model.branchcollection import GenericBranchCollection
 
247
        from lp.services.job.model.job import Job
 
248
        contexts = [job.context for job in jobs]
 
249
        load_related(Job, contexts, ['jobID'])
 
250
        branches = load_related(Branch, contexts, ['branchID'])
 
251
        GenericBranchCollection.preloadDataForBranches(branches)
 
252
        load_related(Product, branches, ['productID'])
 
253
 
 
254
    @classmethod
229
255
    def getByBranch(cls, branch):
230
256
        """See `ITranslationTemplatesBuildJobSource`."""
231
257
        store = IStore(BranchJob)