~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/soyuz/model/buildpackagejob.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 2009 Canonical Ltd.  This software is licensed under the
 
1
# Copyright 2009-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
22
22
from lp.buildmaster.interfaces.builder import IBuilderSet
23
23
from lp.buildmaster.model.buildfarmjob import BuildFarmJobOldDerived
24
24
from lp.registry.interfaces.pocket import PackagePublishingPocket
 
25
from lp.services.database.bulk import load_related
 
26
from lp.services.database.lpstorm import IStore
25
27
from lp.services.database.sqlbase import sqlvalues
26
28
from lp.soyuz.enums import (
27
29
    ArchivePurpose,
62
64
        We override this to provide a delegate specific to package builds."""
63
65
        self.build_farm_job = BuildFarmBuildJob(self.build)
64
66
 
 
67
    @staticmethod
 
68
    def preloadBuildFarmJobs(jobs):
 
69
        from lp.soyuz.model.binarypackagebuild import BinaryPackageBuild
 
70
        return list(IStore(BinaryPackageBuild).find(
 
71
            BinaryPackageBuild,
 
72
            [BuildPackageJob.id.is_in([job.id for job in jobs]),
 
73
             BuildPackageJob.build_id == BinaryPackageBuild.id]))
 
74
 
65
75
    def score(self):
66
76
        """See `IBuildPackageJob`."""
67
77
        # Define a table we'll use to calculate the score based on the time
156
166
        """See `IBuildFarmJob`."""
157
167
        return self.build.is_virtualized
158
168
 
 
169
    @classmethod
 
170
    def preloadJobsData(cls, jobs):
 
171
        from lp.soyuz.model.binarypackagebuild import BinaryPackageBuild
 
172
        from lp.services.job.model.job import Job
 
173
        load_related(Job, jobs, ['job_id'])
 
174
        builds = load_related(BinaryPackageBuild, jobs, ['build_id'])
 
175
        getUtility(IBinaryPackageBuildSet).preloadBuildsData(list(builds))
 
176
 
159
177
    @staticmethod
160
178
    def addCandidateSelectionCriteria(processor, virtualized):
161
179
        """See `IBuildFarmJob`."""