← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~cjwatson/launchpad/optimise-dspr-sample-binary-packages into lp:launchpad

 

Colin Watson has proposed merging lp:~cjwatson/launchpad/optimise-dspr-sample-binary-packages into lp:launchpad.

Commit message:
Reduce the work done in materialising the result of DistributionSourcePackageRelease.sample_binary_packages.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #1769979 in Launchpad itself: "lp times out for source package pages with some more binary packages"
  https://bugs.launchpad.net/launchpad/+bug/1769979

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/optimise-dspr-sample-binary-packages/+merge/345358
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/optimise-dspr-sample-binary-packages into lp:launchpad.
=== modified file 'lib/lp/soyuz/model/distributionsourcepackagerelease.py'
--- lib/lp/soyuz/model/distributionsourcepackagerelease.py	2015-07-09 20:06:17 +0000
+++ lib/lp/soyuz/model/distributionsourcepackagerelease.py	2018-05-10 12:33:43 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009-2011 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2018 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Classes to represent source package releases in a distribution."""
@@ -136,7 +136,7 @@
     @property
     def sample_binary_packages(self):
         """See IDistributionSourcePackageRelease."""
-        #avoid circular imports.
+        # Avoid circular imports.
         from lp.registry.model.distroseries import DistroSeries
         from lp.soyuz.model.distroarchseries import DistroArchSeries
         from lp.soyuz.model.distroseriespackagecache import (
@@ -144,8 +144,7 @@
         archive_ids = list(self.distribution.all_distro_archive_ids)
         result_row = (
             SQL('DISTINCT ON(BinaryPackageName.name) 0 AS ignore'),
-            BinaryPackagePublishingHistory, DistroSeriesPackageCache,
-            BinaryPackageRelease, BinaryPackageName)
+            DistroSeries, BinaryPackageName, DistroSeriesPackageCache)
         tables = (
             BinaryPackagePublishingHistory,
             Join(
@@ -184,12 +183,8 @@
             BinaryPackageName.name)
 
         def make_dsb_package(row):
-            publishing = row[1]
-            package_cache = row[2]
-            return DistroSeriesBinaryPackage(
-                publishing.distroarchseries.distroseries,
-                publishing.binarypackagerelease.binarypackagename,
-                package_cache)
+            _, ds, bpn, package_cache = row
+            return DistroSeriesBinaryPackage(ds, bpn, package_cache)
         return DecoratedResultSet(all_published, make_dsb_package)
 
     def getBinariesForSeries(self, distroseries):


Follow ups