~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/soyuz/browser/builder.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:
41
41
    IBuilder,
42
42
    IBuilderSet,
43
43
    )
 
44
from lp.buildmaster.model.buildqueue import BuildQueue
 
45
from lp.services.database.decoratedresultset import DecoratedResultSet
 
46
from lp.services.database.lpstorm import IStore
44
47
from lp.services.propertycache import cachedproperty
45
48
from lp.services.webapp import (
46
49
    ApplicationMenu,
144
147
    @cachedproperty
145
148
    def builders(self):
146
149
        """All active builders"""
147
 
        return list(self.context.getBuilders())
 
150
        def do_eager_load(builders):
 
151
            # Prefetch the jobs' data.
 
152
            queues = IStore(BuildQueue).find(
 
153
                BuildQueue,
 
154
                BuildQueue.builderID.is_in(
 
155
                    builder.id for builder in builders))
 
156
            BuildQueue.preloadSpecificJobData(queues)
 
157
 
 
158
        return list(DecoratedResultSet(
 
159
            list(self.context.getBuilders()), pre_iter_hook=do_eager_load))
148
160
 
149
161
    @property
150
162
    def number_of_registered_builders(self):