~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/buildmaster/model/buildqueue.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:
16
16
    datetime,
17
17
    timedelta,
18
18
    )
 
19
from itertools import groupby
19
20
import logging
 
21
from operator import attrgetter
20
22
 
21
23
import pytz
22
24
from sqlobject import (
142
144
        specific_class = specific_job_classes()[self.job_type]
143
145
        return specific_class.getByJob(self.job)
144
146
 
 
147
    @staticmethod
 
148
    def preloadSpecificJobData(queues):
 
149
        key = attrgetter('job_type')
 
150
        for job_type, grouped_queues in groupby(queues, key=key):
 
151
            specific_class = specific_job_classes()[job_type]
 
152
            queue_subset = list(grouped_queues)
 
153
            # We need to preload the build farm jobs early to avoid
 
154
            # the call to _set_build_farm_job to look up BuildFarmBuildJobs
 
155
            # one by one.
 
156
            specific_class.preloadBuildFarmJobs(queue_subset)
 
157
            specific_jobs = specific_class.getByJobs(queue_subset)
 
158
            if len(list(specific_jobs)) == 0:
 
159
                continue
 
160
            specific_class.preloadJobsData(specific_jobs)
 
161
 
145
162
    @property
146
163
    def date_started(self):
147
164
        """See `IBuildQueue`."""