~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/soyuz/model/binarypackagebuild.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:
865
865
            return None
866
866
        return resulting_tuple[0]
867
867
 
 
868
    def preloadBuildsData(self, builds):
 
869
        # Circular imports.
 
870
        from lp.soyuz.model.distroarchseries import (
 
871
            DistroArchSeries
 
872
            )
 
873
        from lp.registry.model.distroseries import (
 
874
            DistroSeries
 
875
            )
 
876
        from lp.registry.model.distribution import (
 
877
            Distribution
 
878
            )
 
879
        from lp.soyuz.model.archive import Archive
 
880
        from lp.registry.model.person import Person
 
881
        self._prefetchBuildData(builds)
 
882
        distro_arch_series = load_related(
 
883
            DistroArchSeries, builds, ['distro_arch_series_id'])
 
884
        package_builds = load_related(
 
885
            PackageBuild, builds, ['package_build_id'])
 
886
        archives = load_related(Archive, package_builds, ['archive_id'])
 
887
        load_related(Person, archives, ['ownerID'])
 
888
        distroseries = load_related(
 
889
            DistroSeries, distro_arch_series, ['distroseriesID'])
 
890
        load_related(
 
891
            Distribution, distroseries, ['distributionID'])
 
892
 
868
893
    def getByBuildFarmJobs(self, build_farm_jobs):
869
894
        """See `ISpecificBuildFarmJobSource`."""
870
895
        if len(build_farm_jobs) == 0:
873
898
        build_farm_job_ids = [
874
899
            build_farm_job.id for build_farm_job in build_farm_jobs]
875
900
 
876
 
        def eager_load(rows):
877
 
            # Circular imports.
878
 
            from lp.soyuz.model.distroarchseries import (
879
 
                DistroArchSeries
880
 
                )
881
 
            from lp.registry.model.distroseries import (
882
 
                DistroSeries
883
 
                )
884
 
            from lp.registry.model.distribution import (
885
 
                Distribution
886
 
                )
887
 
            from lp.soyuz.model.archive import Archive
888
 
            from lp.registry.model.person import Person
889
 
            self._prefetchBuildData(rows)
890
 
            distro_arch_series = load_related(
891
 
                DistroArchSeries, rows, ['distro_arch_series_id'])
892
 
            package_builds = load_related(
893
 
                PackageBuild, rows, ['package_build_id'])
894
 
            archives = load_related(Archive, package_builds, ['archive_id'])
895
 
            load_related(Person, archives, ['ownerID'])
896
 
            distroseries = load_related(
897
 
                DistroSeries, distro_arch_series, ['distroseriesID'])
898
 
            load_related(
899
 
                Distribution, distroseries, ['distributionID'])
900
901
        resultset = Store.of(build_farm_jobs[0]).using(*clause_tables).find(
901
902
            BinaryPackageBuild,
902
903
            BinaryPackageBuild.package_build == PackageBuild.id,
903
904
            PackageBuild.build_farm_job == BuildFarmJob.id,
904
905
            BuildFarmJob.id.is_in(build_farm_job_ids))
905
 
        return DecoratedResultSet(resultset, pre_iter_hook=eager_load)
 
906
        return DecoratedResultSet(
 
907
            resultset, pre_iter_hook=self.preloadBuildsData)
906
908
 
907
909
    def getPendingBuildsForArchSet(self, archseries):
908
910
        """See `IBinaryPackageBuildSet`."""