launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #15329
[Merge] lp:~stevenk/launchpad/show-5-pcj-errors into lp:launchpad
Steve Kowalik has proposed merging lp:~stevenk/launchpad/show-5-pcj-errors into lp:launchpad.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
Bug #1149544 in Launchpad itself: "Archive:+packages timeout when too many package copy errors are shown"
https://bugs.launchpad.net/launchpad/+bug/1149544
For more details, see:
https://code.launchpad.net/~stevenk/launchpad/show-5-pcj-errors/+merge/152609
Only show five PCJ notifications in Archive:+packages, also displaying a count if it's greater than 5.
--
https://code.launchpad.net/~stevenk/launchpad/show-5-pcj-errors/+merge/152609
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~stevenk/launchpad/show-5-pcj-errors into lp:launchpad.
=== modified file 'lib/lp/soyuz/browser/archive.py'
--- lib/lp/soyuz/browser/archive.py 2013-03-07 00:51:01 +0000
+++ lib/lp/soyuz/browser/archive.py 2013-03-11 04:19:22 +0000
@@ -1042,13 +1042,20 @@
# Pre-load related source archives.
load_related(Archive, pcjs, ['source_archive_id'])
- return ppcjs
+ return ppcjs.config(limit=5)
@cachedproperty
def has_pending_copy_jobs(self):
return self.package_copy_jobs.any()
@cachedproperty
+ def pending_copy_jobs_text(self):
+ job_source = getUtility(IPlainPackageCopyJobSource)
+ count = job_source.getIncompleteJobsForArchive(self.context).count()
+ if count > 5:
+ return 'Showing 5 of %s' % count
+
+ @cachedproperty
def has_append_perm(self):
return check_permission('launchpad.Append', self.context)
=== modified file 'lib/lp/soyuz/browser/tests/test_archive_packages.py'
--- lib/lp/soyuz/browser/tests/test_archive_packages.py 2013-02-18 09:14:26 +0000
+++ lib/lp/soyuz/browser/tests/test_archive_packages.py 2013-03-11 04:19:22 +0000
@@ -11,6 +11,7 @@
import re
+from BeautifulSoup import BeautifulSoup
import soupmatchers
from testtools.matchers import (
Equals,
@@ -382,6 +383,22 @@
attrs={'class': 'pending-job', 'job_id': job3.id}),
)
self.assertThat(html, packages_matches)
+ self.assertEquals(
+ [], BeautifulSoup(html).findAll(
+ 'span', text=re.compile('Showing 5 of .')))
+
+ def test_job_notifications_display_multiple_is_capped(self):
+ jobs = [self.makeJob('package%d' % i) for i in range(7)]
+ with person_logged_in(self.archive.owner):
+ view = create_initialized_view(
+ self.archive, "+packages", principal=self.archive.owner)
+ soup = BeautifulSoup(view.render())
+ self.assertEquals([],
+ soup.findAll(
+ 'div', attrs={'class': 'pending-job', 'job_id': jobs[-1].id}))
+ self.assertEquals(
+ [u'Showing 5 of 7'],
+ soup.findAll('span', text=re.compile('Showing 5 of .')))
def test_job_notifications_display_owner_is_team(self):
team = self.factory.makeTeam()
=== modified file 'lib/lp/soyuz/templates/archive-packages.pt'
--- lib/lp/soyuz/templates/archive-packages.pt 2012-03-10 15:33:33 +0000
+++ lib/lp/soyuz/templates/archive-packages.pt 2013-03-11 04:19:22 +0000
@@ -132,6 +132,8 @@
<div tal:condition="view/has_pending_copy_jobs">
<div class="copy-job-message">
+ <span tal:condition="view/pending_copy_jobs_text"
+ tal:content="view/pending_copy_jobs_text"/>
<tal:jobs tal:repeat="job view/package_copy_jobs">
<div class="pending-job" tal:attributes="job_id job/id">
<a href="" class="job-summary js-action">