← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~wgrant/launchpad/more-bpn-fixes into lp:launchpad

 

William Grant has proposed merging lp:~wgrant/launchpad/more-bpn-fixes into lp:launchpad.

Requested reviews:
  William Grant (wgrant): code

For more details, see:
https://code.launchpad.net/~wgrant/launchpad/more-bpn-fixes/+merge/124096

Fix more queries to filter on BPPH.bpn rather than BPR.bpn where it is an obvious improvement.
-- 
https://code.launchpad.net/~wgrant/launchpad/more-bpn-fixes/+merge/124096
Your team Launchpad code reviewers is subscribed to branch lp:launchpad.
=== modified file 'lib/lp/soyuz/adapters/overrides.py'
--- lib/lp/soyuz/adapters/overrides.py	2012-07-05 09:58:58 +0000
+++ lib/lp/soyuz/adapters/overrides.py	2012-09-13 04:11:21 +0000
@@ -36,7 +36,6 @@
 from lp.soyuz.interfaces.component import IComponentSet
 from lp.soyuz.interfaces.publishing import active_publishing_status
 from lp.soyuz.model.binarypackagename import BinaryPackageName
-from lp.soyuz.model.binarypackagerelease import BinaryPackageRelease
 from lp.soyuz.model.component import Component
 from lp.soyuz.model.distroarchseries import DistroArchSeries
 from lp.soyuz.model.publishing import (
@@ -241,23 +240,21 @@
             return []
         already_published = DecoratedResultSet(
             store.find(
-                (BinaryPackageRelease.binarypackagenameID,
+                (BinaryPackagePublishingHistory.binarypackagenameID,
                  BinaryPackagePublishingHistory.distroarchseriesID,
                  BinaryPackagePublishingHistory.componentID,
                  BinaryPackagePublishingHistory.sectionID,
                  BinaryPackagePublishingHistory.priority),
                 BinaryPackagePublishingHistory.status.is_in(
                     active_publishing_status),
-                BinaryPackageRelease.id ==
-                    BinaryPackagePublishingHistory.binarypackagereleaseID,
                 Or(*candidates)).order_by(
                     BinaryPackagePublishingHistory.distroarchseriesID,
-                    BinaryPackageRelease.binarypackagenameID,
+                    BinaryPackagePublishingHistory.binarypackagenameID,
                     Desc(BinaryPackagePublishingHistory.datecreated),
                     Desc(BinaryPackagePublishingHistory.id),
                 ).config(distinct=(
                     BinaryPackagePublishingHistory.distroarchseriesID,
-                    BinaryPackageRelease.binarypackagenameID,
+                    BinaryPackagePublishingHistory.binarypackagenameID,
                     )
                 ),
             id_resolver(
@@ -383,7 +380,7 @@
     return And(
         BinaryPackagePublishingHistory.archiveID == archive.id,
         BinaryPackagePublishingHistory.distroarchseriesID == das.id,
-        BinaryPackageRelease.binarypackagenameID == bpn.id)
+        BinaryPackagePublishingHistory.binarypackagenameID == bpn.id)
 
 
 def id_resolver(lookups):

=== modified file 'lib/lp/soyuz/model/archive.py'
--- lib/lp/soyuz/model/archive.py	2012-09-07 05:43:28 +0000
+++ lib/lp/soyuz/model/archive.py	2012-09-13 04:11:21 +0000
@@ -1593,14 +1593,15 @@
         store = getUtility(IStoreSelector).get(MAIN_STORE, DEFAULT_FLAVOR)
         results = store.find(
             BinaryPackageRelease,
-            BinaryPackageRelease.binarypackagename == name,
+            BinaryPackagePublishingHistory.archive == self,
+            BinaryPackagePublishingHistory.binarypackagename == name,
+            BinaryPackagePublishingHistory.binarypackagereleaseID ==
+                BinaryPackageRelease.id,
             BinaryPackageRelease.version == version,
             BinaryPackageBuild.id == BinaryPackageRelease.buildID,
             DistroArchSeries.id == BinaryPackageBuild.distro_arch_series_id,
             DistroArchSeries.architecturetag == archtag,
-            BinaryPackagePublishingHistory.archive == self,
-            BinaryPackagePublishingHistory.binarypackagereleaseID ==
-                BinaryPackageRelease.id).config(distinct=True)
+            ).config(distinct=True)
         if results.count() > 1:
             return None
         return results.one()

=== modified file 'lib/lp/soyuz/model/distroseriesbinarypackage.py'
--- lib/lp/soyuz/model/distroseriesbinarypackage.py	2011-12-30 06:14:56 +0000
+++ lib/lp/soyuz/model/distroseriesbinarypackage.py	2012-09-13 04:11:21 +0000
@@ -8,6 +8,8 @@
     'DistroSeriesBinaryPackage',
     ]
 
+from operator import attrgetter
+
 from storm.expr import Desc
 from storm.store import Store
 from zope.interface import implements
@@ -101,51 +103,35 @@
         return cache.description
 
     @property
-    def current_publishings(self):
-        """See IDistroSeriesBinaryPackage."""
-        ret = BinaryPackagePublishingHistory.select("""
-            BinaryPackagePublishingHistory.distroarchseries =
-                DistroArchSeries.id AND
-            DistroArchSeries.distroseries = %s AND
-            BinaryPackagePublishingHistory.archive IN %s AND
-            BinaryPackagePublishingHistory.binarypackagerelease =
-                BinaryPackageRelease.id AND
-            BinaryPackageRelease.binarypackagename = %s AND
-            BinaryPackagePublishingHistory.dateremoved is NULL
-            """ % sqlvalues(
-                    self.distroseries,
-                    self.distroseries.distribution.all_distro_archive_ids,
-                    self.binarypackagename),
-            orderBy=['-datecreated'],
-            clauseTables=['DistroArchSeries', 'BinaryPackageRelease'])
-        return sorted(ret, key=lambda a: (
-            a.distroarchseries.architecturetag,
-            a.datecreated))
-
-    @property
-    def last_published(self):
-        """See `IDistroSeriesBinaryPackage`."""
+    def _current_publishings(self):
         # Import here so as to avoid circular import.
         from lp.soyuz.model.distroarchseries import (
             DistroArchSeries)
-
-        store = Store.of(self.distroseries)
-
-        publishing_history = store.find(
+        return Store.of(self.distroseries).find(
             BinaryPackagePublishingHistory,
             BinaryPackagePublishingHistory.distroarchseries ==
                 DistroArchSeries.id,
             DistroArchSeries.distroseries == self.distroseries,
             BinaryPackagePublishingHistory.binarypackagerelease ==
                 BinaryPackageRelease.id,
-            BinaryPackageRelease.binarypackagename == self.binarypackagename,
+            BinaryPackagePublishingHistory.binarypackagename ==
+                self.binarypackagename,
             BinaryPackagePublishingHistory.archiveID.is_in(
                 self.distribution.all_distro_archive_ids),
             BinaryPackagePublishingHistory.dateremoved == None)
 
-        last_published_history = publishing_history.order_by(
+    @property
+    def current_publishings(self):
+        """See IDistroSeriesBinaryPackage."""
+        return sorted(
+            self._current_publishings,
+            key=attrgetter('distroarchseries.architecturetag', 'datecreated'))
+
+    @property
+    def last_published(self):
+        """See `IDistroSeriesBinaryPackage`."""
+        last_published_history = self._current_publishings.order_by(
             Desc(BinaryPackagePublishingHistory.datepublished)).first()
-
         if last_published_history is None:
             return None
         else:

=== modified file 'lib/lp/soyuz/model/distroseriespackagecache.py'
--- lib/lp/soyuz/model/distroseriespackagecache.py	2011-12-30 06:14:56 +0000
+++ lib/lp/soyuz/model/distroseriespackagecache.py	2012-09-13 04:11:21 +0000
@@ -88,7 +88,7 @@
             BinaryPackagePublishingHistory.archive = Archive.id AND
             BinaryPackagePublishingHistory.binarypackagerelease =
                 BinaryPackageRelease.id AND
-            BinaryPackageRelease.binarypackagename =
+            BinaryPackagePublishingHistory.binarypackagename =
                 BinaryPackageName.id AND
             BinaryPackagePublishingHistory.dateremoved is NULL AND
             Archive.enabled = TRUE
@@ -120,9 +120,10 @@
         # get the set of published binarypackagereleases
         bprs = IStore(BinaryPackageRelease).find(
             BinaryPackageRelease,
-            BinaryPackageRelease.binarypackagename == binarypackagename,
             BinaryPackageRelease.id ==
                 BinaryPackagePublishingHistory.binarypackagereleaseID,
+            BinaryPackagePublishingHistory.binarypackagename ==
+                binarypackagename,
             BinaryPackagePublishingHistory.distroarchseriesID ==
                 DistroArchSeries.id,
             DistroArchSeries.distroseries == distroseries,
@@ -193,9 +194,8 @@
             BinaryPackagePublishingHistory.distroarchseriesID ==
                 DistroArchSeries.id,
             BinaryPackagePublishingHistory.archive == archive,
-            BinaryPackagePublishingHistory.binarypackagereleaseID ==
-                BinaryPackageRelease.id,
-            BinaryPackageRelease.binarypackagename == BinaryPackageName.id,
+            BinaryPackagePublishingHistory.binarypackagename ==
+                BinaryPackageName.id,
             BinaryPackagePublishingHistory.dateremoved == None).config(
                 distinct=True).order_by(BinaryPackageName.name)
 

=== modified file 'lib/lp/soyuz/model/publishing.py'
--- lib/lp/soyuz/model/publishing.py	2012-07-05 22:45:45 +0000
+++ lib/lp/soyuz/model/publishing.py	2012-09-13 04:11:21 +0000
@@ -1466,7 +1466,7 @@
                 BinaryPackagePublishingHistory.archiveID ==
                     get_archive(archive, bpr).id,
                 BinaryPackagePublishingHistory.distroarchseriesID == das.id,
-                BinaryPackageRelease.binarypackagenameID ==
+                BinaryPackagePublishingHistory.binarypackagenameID ==
                     bpr.binarypackagenameID,
                 BinaryPackageRelease.version == bpr.version,
                 )


Follow ups