launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #14906
[Merge] lp:~stevenk/launchpad/no-count-distribution-ppas into lp:launchpad
Steve Kowalik has proposed merging lp:~stevenk/launchpad/no-count-distribution-ppas into lp:launchpad.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
Bug #790535 in Launchpad itself: "Distribution:+ppas timeouts"
https://bugs.launchpad.net/launchpad/+bug/790535
For more details, see:
https://code.launchpad.net/~stevenk/launchpad/no-count-distribution-ppas/+merge/142818
Delete the PPA statistics from Distribution:+ppas, and the methods that the properties back onto. Due to the TAL requiring registered_ppas to work out whether to allow search, I wrote another method on the view that backs onto IDistribution.getAllPPAs() -- since that returns a ResultSet, hopefully calling is_empty() on it means it's performant.
--
https://code.launchpad.net/~stevenk/launchpad/no-count-distribution-ppas/+merge/142818
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~stevenk/launchpad/no-count-distribution-ppas into lp:launchpad.
=== modified file 'lib/lp/registry/browser/distribution.py'
--- lib/lp/registry/browser/distribution.py 2012-09-21 06:52:06 +0000
+++ lib/lp/registry/browser/distribution.py 2013-01-11 00:27:23 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009-2011 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2013 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Browser views for distributions."""
@@ -780,32 +780,8 @@
return self.batchnav.currentBatch()
@property
- def number_of_registered_ppas(self):
- """The number of archives with PPA purpose.
-
- It doesn't include private PPAs.
- """
- return self.context.searchPPAs(show_inactive=True).count()
-
- @property
- def number_of_active_ppas(self):
- """The number of PPAs with at least one source publication.
-
- It doesn't include private PPAs.
- """
- return self.context.searchPPAs(show_inactive=False).count()
-
- @property
- def number_of_ppa_sources(self):
- """The number of sources published across all PPAs."""
- return getUtility(IArchiveSet).getNumberOfPPASourcesForDistribution(
- self.context)
-
- @property
- def number_of_ppa_binaries(self):
- """The number of binaries published across all PPAs."""
- return getUtility(IArchiveSet).getNumberOfPPABinariesForDistribution(
- self.context)
+ def distribution_has_ppas(self):
+ return not self.context.getAllPPAs().is_empty()
@property
def latest_ppa_source_publications(self):
=== modified file 'lib/lp/soyuz/doc/archive.txt'
--- lib/lp/soyuz/doc/archive.txt 2012-12-26 01:32:19 +0000
+++ lib/lp/soyuz/doc/archive.txt 2013-01-11 00:27:23 +0000
@@ -1118,79 +1118,6 @@
>>> print sorted(set(archive_purposes))
['COPY', 'DEBUG', 'PARTNER', 'PPA', 'PRIMARY']
-ArchiveSet utility also offers counters in the distribution context for:
-
- * The number of published sources in public PPAs
- (getNumberOfPPASourcesForDistribution);
-
- * The number of published binaries in public PPAs
- (getNumberOfPPABinariesForDistribution);
-
-Those counters are obtained from the cached package counters for each
-PPA, so they will change when the caches get updated.
-
-Those counters explicity exclude packages in private PPAs.
-
-The current counters says we only have 4 source and 4 binary published
-in public PPAs.
-
- >>> archive_set.getNumberOfPPASourcesForDistribution(ubuntu)
- 4
- >>> archive_set.getNumberOfPPABinariesForDistribution(ubuntu)
- 4
-
-As mentioned caches for private PPAs are not considered.
-
- >>> print cprov_private_ppa.private
- True
-
- >>> cprov_private_ppa.sources_cached
- 0
- >>> cprov_private_ppa.binaries_cached
- 0
-
- >>> from zope.security.proxy import removeSecurityProxy
- >>> naked_cprov_archive = removeSecurityProxy(cprov_private_ppa)
- >>> naked_cprov_archive.sources_cached = 1000
- >>> naked_cprov_archive.binaries_cached = 2000
- >>> naked_cprov_archive.syncUpdate()
-
- >>> archive_set.getNumberOfPPASourcesForDistribution(ubuntu)
- 4
- >>> archive_set.getNumberOfPPABinariesForDistribution(ubuntu)
- 4
-
-On the other hand, changes in the a public PPA are immediately
-considered.
-
- >>> print no_priv.archive.private
- False
-
- >>> no_priv.archive.sources_cached
- 0
- >>> no_priv.archive.binaries_cached
- 0
- >>> naked_no_priv_archive = removeSecurityProxy(no_priv.archive)
- >>> naked_no_priv_archive.sources_cached = 10
- >>> naked_no_priv_archive.binaries_cached = 2
- >>> naked_no_priv_archive.syncUpdate()
-
- >>> archive_set.getNumberOfPPASourcesForDistribution(ubuntu)
- 14
- >>> archive_set.getNumberOfPPABinariesForDistribution(ubuntu)
- 6
-
-Since we currently only create archives for ubuntu distribution, the
-counters for other distributions are always 'zero'.
-
- >>> debian = getUtility(IDistributionSet).getByName('debian')
-
- >>> archive_set.getNumberOfPPASourcesForDistribution(debian)
- 0
-
- >>> archive_set.getNumberOfPPABinariesForDistribution(debian)
- 0
-
'getPPAsForUser' returns all the PPAs a given user participates in. It
uses `TeamParticipation` relationships to calculate all the PPAs the
user is allowed to upload or copy packages to.
=== modified file 'lib/lp/soyuz/interfaces/archive.py'
--- lib/lp/soyuz/interfaces/archive.py 2013-01-07 02:40:55 +0000
+++ lib/lp/soyuz/interfaces/archive.py 2013-01-11 00:27:23 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009-2012 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2013 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Archive interfaces."""
@@ -1974,18 +1974,6 @@
title = Attribute('Title')
- def getNumberOfPPASourcesForDistribution(distribution):
- """Return the number of sources for PPAs in a given distribution.
-
- Only public and published sources are considered.
- """
-
- def getNumberOfPPABinariesForDistribution(distribution):
- """Return the number of binaries for PPAs in a given distribution.
-
- Only public and published sources are considered.
- """
-
def new(purpose, owner, name=None, displayname=None, distribution=None,
description=None, enabled=True, require_virtualized=True,
private=False, suppress_subscription_notifications=False):
=== modified file 'lib/lp/soyuz/model/archive.py'
--- lib/lp/soyuz/model/archive.py 2013-01-02 06:05:27 +0000
+++ lib/lp/soyuz/model/archive.py 2013-01-11 00:27:23 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009-2012 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2013 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Database class for table Archive."""
@@ -2305,32 +2305,6 @@
"""See `IArchiveSet`."""
return iter(Archive.select())
- def getNumberOfPPASourcesForDistribution(self, distribution):
- cur = cursor()
- query = """
- SELECT SUM(sources_cached) FROM Archive
- WHERE purpose = %s AND private = FALSE AND
- distribution = %s
- """ % sqlvalues(ArchivePurpose.PPA, distribution)
- cur.execute(query)
- size = cur.fetchall()[0][0]
- if size is None:
- return 0
- return int(size)
-
- def getNumberOfPPABinariesForDistribution(self, distribution):
- cur = cursor()
- query = """
- SELECT SUM(binaries_cached) FROM Archive
- WHERE purpose = %s AND private = FALSE AND
- distribution = %s
- """ % sqlvalues(ArchivePurpose.PPA, distribution)
- cur.execute(query)
- size = cur.fetchall()[0][0]
- if size is None:
- return 0
- return int(size)
-
def getPPAOwnedByPerson(self, person, name=None, statuses=None,
has_packages=False):
"""See `IArchiveSet`."""
=== modified file 'lib/lp/soyuz/stories/ppa/xx-ubuntu-ppas.txt'
--- lib/lp/soyuz/stories/ppa/xx-ubuntu-ppas.txt 2012-08-09 11:23:20 +0000
+++ lib/lp/soyuz/stories/ppa/xx-ubuntu-ppas.txt 2013-01-11 00:27:23 +0000
@@ -30,22 +30,6 @@
Hoary (5.04) - development i386 (official)
Warty (4.10) - current i386 (official)
-The sample data contains three PPAs. Only Celso's and Mark's have
-packages (the active ones). Altogether there 4 sources and 4 binaries
-published across all ubuntu PPAs.
-
- >>> print extract_text(
- ... find_tag_by_id(anon_browser.contents, 'ppa_statistics'))
- Statistics
- Registered PPAs:
- 3
- Active PPAs:
- 2
- Published sources:
- 4
- Published binaries:
- 4
-
Up to 5 latest source publications are also presented in the 'Latest
sources' section.
@@ -90,13 +74,6 @@
Sarge (3.1) - frozen
Woody (3.0) - current i386 (official)
-Archive and package counter are empty.
-
- >>> print extract_text(
- ... find_tag_by_id(anon_browser.contents, 'ppa_statistics'))
- Statistics
- Debian does not have any registered PPA.
-
'Latest uploads' section is not presented.
>>> print find_tag_by_id(anon_browser.contents, 'ppa_latest_uploads')
@@ -140,9 +117,6 @@
When a search is requested the information sections are not rendered.
- >>> print find_tag_by_id(anon_browser.contents, 'ppa_statistics')
- None
-
>>> print find_tag_by_id(anon_browser.contents, 'ppa_most_active')
None
@@ -160,10 +134,6 @@
>>> anon_browser.open("http://launchpad.dev/ubuntu/+ppas")
>>> find_tag_by_id(
- ... anon_browser.contents, 'ppa_statistics') is not None
- True
-
- >>> find_tag_by_id(
... anon_browser.contents, 'ppa_most_active') is not None
True
=== modified file 'lib/lp/soyuz/templates/distribution-ppa-list.pt'
--- lib/lp/soyuz/templates/distribution-ppa-list.pt 2010-10-10 21:54:16 +0000
+++ lib/lp/soyuz/templates/distribution-ppa-list.pt 2013-01-11 00:27:23 +0000
@@ -9,8 +9,7 @@
<body>
<div metal:fill-slot="main"
- tal:define="registered_ppas view/number_of_registered_ppas;
- batch view/search_results;
+ tal:define="batch view/search_results;
no_search python:not (view.name_filter or batch);
empty_results python:view.name_filter and not batch">
@@ -24,7 +23,7 @@
>help page</a>.</p>
<form name="ppa_search" action="" method="GET"
- tal:condition="registered_ppas">
+ tal:condition="view/distribution_has_ppas">
<p>Search user-contributed software packages published in any
<tal:distribution replace="context/title"
>Ubuntu</tal:distribution> PPA.</p>
@@ -55,34 +54,8 @@
<div class="yui-u first">
- <div id="ppa_statistics" class="portlet">
- <h2>Statistics</h2>
- <div class="two-column-list" tal:condition="registered_ppas">
- <dl>
- <dt> Registered PPAs:</dt>
- <dd tal:content="registered_ppas">10</dd>
- </dl>
- <dl>
- <dt>Active PPAs:</dt>
- <dd tal:content="view/number_of_active_ppas">4</dd>
- </dl>
- <dl>
- <dt>Published sources:</dt>
- <dd tal:content="view/number_of_ppa_sources">20</dd>
- </dl>
- <dl>
- <dt>Published binaries:</dt>
- <dd tal:content="view/number_of_ppa_binaries">20</dd>
- </dl>
- </div>
- <p tal:condition="not: registered_ppas">
- <span tal:replace="context/displayname">Ubuntu Linux</span>
- does not have any registered PPA.
- </p>
- </div> <!-- ppa_statistics -->
-
<div id="ppa_latest_uploads" class="portlet"
- tal:condition="registered_ppas">
+ tal:condition="view/distribution_has_ppas">
<h2>Latest uploads</h2>
<ul class="source package">
<li class="sprite package-source"
@@ -99,7 +72,7 @@
</div> <!-- ppa_latest_uploads -->
<div id="ppa_most_active" class="portlet"
- tal:condition="registered_ppas">
+ tal:condition="view/distribution_has_ppas">
<h2>Most active</h2>
<p>PPAs with the highest number of uploads in the
last 7 days.</p>