Merge lp:~cjwatson/launchpad/optimise-built-packages into lp:launchpad

Proposed by Colin Watson
Status: Merged
Merged at revision: 18668
Proposed branch: lp:~cjwatson/launchpad/optimise-built-packages
Merge into: lp:launchpad
Diff against target: 113 lines (+35/-16)
4 files modified
lib/lp/soyuz/browser/publishing.py (+5/-13)
lib/lp/soyuz/interfaces/publishing.py (+10/-1)
lib/lp/soyuz/model/publishing.py (+16/-0)
lib/lp/soyuz/templates/sourcepackagepublishinghistory-listing-archive-extra.pt (+4/-2)
To merge this branch: bzr merge lp:~cjwatson/launchpad/optimise-built-packages
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+346738@code.launchpad.net

Commit message

Optimise "Built packages" section of SPPH:+listing-archive-extra.

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/soyuz/browser/publishing.py'
--- lib/lp/soyuz/browser/publishing.py 2018-05-11 17:52:37 +0000
+++ lib/lp/soyuz/browser/publishing.py 2018-05-23 13:45:59 +0000
@@ -15,6 +15,7 @@
15from operator import attrgetter15from operator import attrgetter
1616
17from lazr.delegates import delegate_to17from lazr.delegates import delegate_to
18from zope.component import getUtility
18from zope.interface import implementer19from zope.interface import implementer
1920
20from lp.archiveuploader.utils import re_isadeb21from lp.archiveuploader.utils import re_isadeb
@@ -37,6 +38,7 @@
37from lp.soyuz.interfaces.packagediff import IPackageDiff38from lp.soyuz.interfaces.packagediff import IPackageDiff
38from lp.soyuz.interfaces.publishing import (39from lp.soyuz.interfaces.publishing import (
39 IBinaryPackagePublishingHistory,40 IBinaryPackagePublishingHistory,
41 IPublishingSet,
40 ISourcePackagePublishingHistory,42 ISourcePackagePublishingHistory,
41 )43 )
4244
@@ -317,19 +319,9 @@
317 the binarypackagename is unique (i.e. it ignores the same package319 the binarypackagename is unique (i.e. it ignores the same package
318 published in more than one place/architecture.)320 published in more than one place/architecture.)
319 """321 """
320 results = []322 publishing_set = getUtility(IPublishingSet)
321 packagenames = set()323 return publishing_set.getBuiltPackagesSummaryForSourcePublication(
322 for pub in self.context.getPublishedBinaries():324 self.context)
323 package = pub.binarypackagerelease
324 packagename = package.binarypackagename.name
325 if packagename not in packagenames:
326 entry = {
327 "binarypackagename": packagename,
328 "summary": package.summary,
329 }
330 results.append(entry)
331 packagenames.add(packagename)
332 return results
333325
334 @cachedproperty326 @cachedproperty
335 def builds(self):327 def builds(self):
336328
=== modified file 'lib/lp/soyuz/interfaces/publishing.py'
--- lib/lp/soyuz/interfaces/publishing.py 2016-09-24 06:22:43 +0000
+++ lib/lp/soyuz/interfaces/publishing.py 2018-05-23 13:45:59 +0000
@@ -1,4 +1,4 @@
1# Copyright 2009-2015 Canonical Ltd. This software is licensed under the1# Copyright 2009-2018 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4"""Publishing interfaces."""4"""Publishing interfaces."""
@@ -1040,6 +1040,15 @@
1040 `BinaryPackageRelease`, `BinaryPackageName`, `DistroArchSeries`)1040 `BinaryPackageRelease`, `BinaryPackageName`, `DistroArchSeries`)
1041 """1041 """
10421042
1043 def getBuiltPackagesSummaryForSourcePublication(source_publication):
1044 """Return a summary of the built packages for this source publication.
1045
1046 For each built package from this published source, return a
1047 dictionary with keys "binarypackagename" and "summary", where
1048 the binarypackagename is unique (i.e. it ignores the same package
1049 published in more than one place/architecture.)
1050 """
1051
1043 def getActiveArchSpecificPublications(sourcepackagerelease, archive,1052 def getActiveArchSpecificPublications(sourcepackagerelease, archive,
1044 distroseries, pocket):1053 distroseries, pocket):
1045 """Find architecture-specific binary publications for a source.1054 """Find architecture-specific binary publications for a source.
10461055
=== modified file 'lib/lp/soyuz/model/publishing.py'
--- lib/lp/soyuz/model/publishing.py 2018-05-04 21:59:32 +0000
+++ lib/lp/soyuz/model/publishing.py 2018-05-23 13:45:59 +0000
@@ -1448,6 +1448,22 @@
14481448
1449 return result_set1449 return result_set
14501450
1451 def getBuiltPackagesSummaryForSourcePublication(self, source_publication):
1452 """See `IPublishingSet`."""
1453 result_set = IStore(BinaryPackageName).find(
1454 (BinaryPackageName.name, BinaryPackageRelease.summary,
1455 DistroArchSeries.architecturetag,
1456 BinaryPackagePublishingHistory.id),
1457 self._getSourceBinaryJoinForSources([source_publication.id]))
1458 result_set.config(distinct=(BinaryPackageName.name,))
1459 result_set.order_by(
1460 BinaryPackageName.name,
1461 DistroArchSeries.architecturetag,
1462 Desc(BinaryPackagePublishingHistory.id))
1463 return [
1464 {"binarypackagename": name, "summary": summary}
1465 for name, summary, _, _ in result_set]
1466
1451 def getActiveArchSpecificPublications(self, sourcepackagerelease, archive,1467 def getActiveArchSpecificPublications(self, sourcepackagerelease, archive,
1452 distroseries, pocket):1468 distroseries, pocket):
1453 """See `IPublishingSet`."""1469 """See `IPublishingSet`."""
14541470
=== modified file 'lib/lp/soyuz/templates/sourcepackagepublishinghistory-listing-archive-extra.pt'
--- lib/lp/soyuz/templates/sourcepackagepublishinghistory-listing-archive-extra.pt 2010-05-27 22:18:16 +0000
+++ lib/lp/soyuz/templates/sourcepackagepublishinghistory-listing-archive-extra.pt 2018-05-23 13:45:59 +0000
@@ -38,9 +38,11 @@
38 </li>38 </li>
39 </ul>39 </ul>
4040
41 <tal:built-packages condition="view/built_packages" omit-tag="">41 <tal:built-packages
42 define="built_packages view/built_packages"
43 condition="built_packages" omit-tag="">
42 <h3>Built packages</h3>44 <h3>Built packages</h3>
43 <ul tal:repeat="package view/built_packages"45 <ul tal:repeat="package built_packages"
44 style="margin-top: 0; margin-bottom: 0">46 style="margin-top: 0; margin-bottom: 0">
45 <li>47 <li>
46 <b><tal:name replace="package/binarypackagename"/></b>48 <b><tal:name replace="package/binarypackagename"/></b>