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
1=== modified file 'lib/lp/soyuz/browser/publishing.py'
2--- lib/lp/soyuz/browser/publishing.py 2018-05-11 17:52:37 +0000
3+++ lib/lp/soyuz/browser/publishing.py 2018-05-23 13:45:59 +0000
4@@ -15,6 +15,7 @@
5 from operator import attrgetter
6
7 from lazr.delegates import delegate_to
8+from zope.component import getUtility
9 from zope.interface import implementer
10
11 from lp.archiveuploader.utils import re_isadeb
12@@ -37,6 +38,7 @@
13 from lp.soyuz.interfaces.packagediff import IPackageDiff
14 from lp.soyuz.interfaces.publishing import (
15 IBinaryPackagePublishingHistory,
16+ IPublishingSet,
17 ISourcePackagePublishingHistory,
18 )
19
20@@ -317,19 +319,9 @@
21 the binarypackagename is unique (i.e. it ignores the same package
22 published in more than one place/architecture.)
23 """
24- results = []
25- packagenames = set()
26- for pub in self.context.getPublishedBinaries():
27- package = pub.binarypackagerelease
28- packagename = package.binarypackagename.name
29- if packagename not in packagenames:
30- entry = {
31- "binarypackagename": packagename,
32- "summary": package.summary,
33- }
34- results.append(entry)
35- packagenames.add(packagename)
36- return results
37+ publishing_set = getUtility(IPublishingSet)
38+ return publishing_set.getBuiltPackagesSummaryForSourcePublication(
39+ self.context)
40
41 @cachedproperty
42 def builds(self):
43
44=== modified file 'lib/lp/soyuz/interfaces/publishing.py'
45--- lib/lp/soyuz/interfaces/publishing.py 2016-09-24 06:22:43 +0000
46+++ lib/lp/soyuz/interfaces/publishing.py 2018-05-23 13:45:59 +0000
47@@ -1,4 +1,4 @@
48-# Copyright 2009-2015 Canonical Ltd. This software is licensed under the
49+# Copyright 2009-2018 Canonical Ltd. This software is licensed under the
50 # GNU Affero General Public License version 3 (see the file LICENSE).
51
52 """Publishing interfaces."""
53@@ -1040,6 +1040,15 @@
54 `BinaryPackageRelease`, `BinaryPackageName`, `DistroArchSeries`)
55 """
56
57+ def getBuiltPackagesSummaryForSourcePublication(source_publication):
58+ """Return a summary of the built packages for this source publication.
59+
60+ For each built package from this published source, return a
61+ dictionary with keys "binarypackagename" and "summary", where
62+ the binarypackagename is unique (i.e. it ignores the same package
63+ published in more than one place/architecture.)
64+ """
65+
66 def getActiveArchSpecificPublications(sourcepackagerelease, archive,
67 distroseries, pocket):
68 """Find architecture-specific binary publications for a source.
69
70=== modified file 'lib/lp/soyuz/model/publishing.py'
71--- lib/lp/soyuz/model/publishing.py 2018-05-04 21:59:32 +0000
72+++ lib/lp/soyuz/model/publishing.py 2018-05-23 13:45:59 +0000
73@@ -1448,6 +1448,22 @@
74
75 return result_set
76
77+ def getBuiltPackagesSummaryForSourcePublication(self, source_publication):
78+ """See `IPublishingSet`."""
79+ result_set = IStore(BinaryPackageName).find(
80+ (BinaryPackageName.name, BinaryPackageRelease.summary,
81+ DistroArchSeries.architecturetag,
82+ BinaryPackagePublishingHistory.id),
83+ self._getSourceBinaryJoinForSources([source_publication.id]))
84+ result_set.config(distinct=(BinaryPackageName.name,))
85+ result_set.order_by(
86+ BinaryPackageName.name,
87+ DistroArchSeries.architecturetag,
88+ Desc(BinaryPackagePublishingHistory.id))
89+ return [
90+ {"binarypackagename": name, "summary": summary}
91+ for name, summary, _, _ in result_set]
92+
93 def getActiveArchSpecificPublications(self, sourcepackagerelease, archive,
94 distroseries, pocket):
95 """See `IPublishingSet`."""
96
97=== modified file 'lib/lp/soyuz/templates/sourcepackagepublishinghistory-listing-archive-extra.pt'
98--- lib/lp/soyuz/templates/sourcepackagepublishinghistory-listing-archive-extra.pt 2010-05-27 22:18:16 +0000
99+++ lib/lp/soyuz/templates/sourcepackagepublishinghistory-listing-archive-extra.pt 2018-05-23 13:45:59 +0000
100@@ -38,9 +38,11 @@
101 </li>
102 </ul>
103
104- <tal:built-packages condition="view/built_packages" omit-tag="">
105+ <tal:built-packages
106+ define="built_packages view/built_packages"
107+ condition="built_packages" omit-tag="">
108 <h3>Built packages</h3>
109- <ul tal:repeat="package view/built_packages"
110+ <ul tal:repeat="package built_packages"
111 style="margin-top: 0; margin-bottom: 0">
112 <li>
113 <b><tal:name replace="package/binarypackagename"/></b>