~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-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 2009-2011 Canonical Ltd.  This software is licensed under the
 
1
# Copyright 2009-2012 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
"""Browser views for builders."""
44
44
from lp.buildmaster.model.buildqueue import BuildQueue
45
45
from lp.services.database.decoratedresultset import DecoratedResultSet
46
46
from lp.services.database.lpstorm import IStore
47
 
from lp.services.propertycache import cachedproperty
 
47
from lp.services.propertycache import (
 
48
    cachedproperty,
 
49
    get_property_cache,
 
50
    )
48
51
from lp.services.webapp import (
49
52
    ApplicationMenu,
50
53
    canonical_url,
148
151
    def builders(self):
149
152
        """All active builders"""
150
153
        def do_eager_load(builders):
151
 
            # Prefetch the jobs' data.
 
154
            # Populate builders' currentjob cachedproperty.
152
155
            queues = IStore(BuildQueue).find(
153
156
                BuildQueue,
154
157
                BuildQueue.builderID.is_in(
155
158
                    builder.id for builder in builders))
 
159
            queue_builders = dict(
 
160
                (queue.builderID, queue) for queue in queues)
 
161
            for builder in builders:
 
162
                cache = get_property_cache(builder)
 
163
                cache.currentjob = queue_builders.get(builder.id, None)
 
164
            # Prefetch the jobs' data.
156
165
            BuildQueue.preloadSpecificJobData(queues)
157
166
 
158
167
        return list(DecoratedResultSet(