Bug#754658: please display the package's description
On Mon, 22 Sep 2014, Paul Wise wrote: Is there an argument for not replacing point (3) above with: (3*) Otherwise, use the description of the first binary in debian/control order My gut feeling is that (2) is enough to counter most of the misleading results that (3*) alone would produce. Sounds good to me. Except that we don't know anything of the order when we extract Packages/Sources files. We do extract debian/control of the source package but it's just to make it available to users currently. There's no post-processing of that file for further uses... Raphael, the PTS also has long descriptions in title attributes of the abbrev tags that enclose short descriptions, could we add that to the distro tracker too? The PTS uses this HTML: smallabbrev title={longdesc}{shortdesc}/abbrev/small It should be doable since we extract it as well. Added to my TODO (Andrew, if you want to take care of it, feel free!). It's just a matter a adding the long_description attribute (and factorizing in a @cached_property the logic to identify the underlying binary package to use). Cheers, -- Raphaël Hertzog ◈ Debian Developer Discover the Debian Administrator's Handbook: → http://debian-handbook.info/get/ -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Bug#754658: please display the package's description
On Thu, Sep 18, 2014 at 6:50 AM, Raphael Hertzog hert...@debian.org wrote: On Tue, 16 Sep 2014, Paul Wise wrote: On Tue, Sep 16, 2014 at 7:40 PM, Ben Hutchings wrote: I think this fall back should not be used, except for packages that build a single binary. It results in nonsense like: The heuristics used by the old PTS are probably better. A summary: Ack. I updated distro-tracker to do that, except that we return an empty string instead of the meaningless source package. After seeing it in use, I also agree. Thanks for fixing it up Raphael. -- Andrew Starr-Bochicchio Ubuntu Developer https://launchpad.net/~andrewsomething Debian Developer http://qa.debian.org/developer.php?login=asb PGP/GPG Key ID: D53FDCB1 -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Bug#754658: please display the package's description
[ quoted text edit to add references ] On Tue, Sep 16, 2014 at 11:39:13PM +0800, Paul Wise wrote: 1) When only one binary package, use the description from it. 2) When more than one binary package but one has the same name as the source package, use the description from that. 3) Otherwise, use source package. Uhm, interesting, I always thought the heuristic was slightly difference. Is there an argument for not replacing point (3) above with: (3*) Otherwise, use the description of the first binary in debian/control order My gut feeling is that (2) is enough to counter most of the misleading results that (3*) alone would produce. Cheers. -- Stefano Zacchiroli . . . . . . . z...@upsilon.cc . . . . o . . . o . o Maître de conférences . . . . . http://upsilon.cc/zack . . . o . . . o o Former Debian Project Leader . . @zack on identi.ca . . o o o . . . o . « the first rule of tautology club is the first rule of tautology club » signature.asc Description: Digital signature
Bug#754658: please display the package's description
On Mon, Sep 22, 2014 at 3:35 AM, Stefano Zacchiroli wrote: Uhm, interesting, I always thought the heuristic was slightly difference. It was always that way FYI. Is there an argument for not replacing point (3) above with: (3*) Otherwise, use the description of the first binary in debian/control order My gut feeling is that (2) is enough to counter most of the misleading results that (3*) alone would produce. Sounds good to me. Raphael, the PTS also has long descriptions in title attributes of the abbrev tags that enclose short descriptions, could we add that to the distro tracker too? The PTS uses this HTML: smallabbrev title={longdesc}{shortdesc}/abbrev/small -- bye, pabs https://wiki.debian.org/PaulWise -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Bug#754658: please display the package's description
On Tue, 16 Sep 2014, Paul Wise wrote: On Tue, Sep 16, 2014 at 7:40 PM, Ben Hutchings wrote: I think this fall back should not be used, except for packages that build a single binary. It results in nonsense like: The heuristics used by the old PTS are probably better. A summary: Ack. I updated distro-tracker to do that, except that we return an empty string instead of the meaningless source package. Cheers, -- Raphaël Hertzog ◈ Debian Developer Discover the Debian Administrator's Handbook: → http://debian-handbook.info/get/ -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Bug#754658: please display the package's description
On Fri, 2014-08-29 at 13:18 -0700, Andrew Starr-Bochicchio wrote: The attached patch adds the short description under the source package name. The current PTS only uses the short description if there is a binary package that has the same name as the source package. If not, it just displays Source package I have decided to fall back to the short description for the first binary package instead. [...] I think this fall back should not be used, except for packages that build a single binary. It results in nonsense like: linux Xen system with Linux 3.16 on 64-bit PCs (meta-package) That description comes from the xen-linux-system-3.16-1-amd64 binary package; I don't how that would be the 'first' binary package. Using the package currently listed first in the control file, we would get: linux Linux kernel source for version 3.16 with Debian patches But this is still not a very sensible summary of the source package. Ben. -- Ben Hutchings Beware of programmers who carry screwdrivers. - Leonard Brandwein signature.asc Description: This is a digitally signed message part
Bug#754658: please display the package's description
On Tue, Sep 16, 2014 at 7:40 PM, Ben Hutchings wrote: I think this fall back should not be used, except for packages that build a single binary. It results in nonsense like: The heuristics used by the old PTS are probably better. A summary: When only one binary package, use the description from it. When more than one binary package but one has the same name as the source package, use the description from that. Otherwise, use source package. -- bye, pabs https://wiki.debian.org/PaulWise -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Bug#754658: please display the package's description
Hi, On Fri, 29 Aug 2014, Andrew Starr-Bochicchio wrote: It should probably be a method of PackageName so that we get the short description for free in any other context... for example in the mail bot when we confirm the subscription or something like that. Makes sense. I think I've addressed all the other issues as well. Hum, not really, it still makes direct queries instead of relying on attributes of the (Source|Binary)PackageName object: +def short_description(self): So in theory this function should in fact be implemented twice: - once in SourcePackageName where it will iterate over self.main_version.binarypackage_set.all() to find the binary package of same name, something along those lines: desc = None for binpkg in self.main_version.binarypackage_set.all(): if desc is None: desc = binpkg.short_description if binpkg.binary_package_name.name = self.name desc = binpkg.short_description break - once in BinaryPackageName where it will iterate over self.binary_package_versions.all() to grab the description from the package with the highest version But for your specific need, you can just do it in SourcePackageName. Sorry if this wasn't clear enough in my previous mail. Cheers, -- Raphaël Hertzog ◈ Debian Developer Discover the Debian Administrator's Handbook: → http://debian-handbook.info/get/ -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Bug#754658: please display the package's description
On Sat, Aug 30, 2014 at 5:29 AM, Raphael Hertzog hert...@debian.org wrote: On Fri, 29 Aug 2014, Andrew Starr-Bochicchio wrote: It should probably be a method of PackageName so that we get the short description for free in any other context... for example in the mail bot when we confirm the subscription or something like that. Makes sense. I think I've addressed all the other issues as well. Hum, not really, it still makes direct queries instead of relying on attributes of the (Source|Binary)PackageName object: I suspect that I'm becoming more annoying than helpful at this point... Let's hope the third time's the charm. Thanks! -- Andrew Starr-Bochicchio Ubuntu Developer https://launchpad.net/~andrewsomething Debian Developer http://qa.debian.org/developer.php?login=asb PGP/GPG Key ID: D53FDCB1 From e9515f0fca46cc13376463c6f4ebd4da35cd1898 Mon Sep 17 00:00:00 2001 From: Andrew Starr-Bochicchio a.star...@gmail.com Date: Fri, 29 Aug 2014 13:05:03 -0700 Subject: [PATCH] Add the short description under the source package name. The current PTS only uses the short description if there is a binary package that has the same name as the source package. If not, it just displays Source package I have decided to fall back to the short description for the first binary package instead. --- distro_tracker/core/models.py | 23 ++ distro_tracker/core/templates/core/package.html | 1 + distro_tracker/core/tests/tests_models.py | 29 + distro_tracker/core/tests/tests_views.py| 56 - 4 files changed, 107 insertions(+), 2 deletions(-) diff --git a/distro_tracker/core/models.py b/distro_tracker/core/models.py index 2a16944..a9c669f 100644 --- a/distro_tracker/core/models.py +++ b/distro_tracker/core/models.py @@ -450,6 +450,29 @@ class SourcePackageName(PackageName): } return Repository.objects.filter(**kwargs).distinct() +def short_description(self): + +Returns the most recent short description for a source package. If there +is a binary package whose name matches the source package, its +description will be used. If not, the short description for the first +binary package will be used. + +desc = None + +try: +binary_packages = self.main_version.binarypackage_set.all() + +for pkg in binary_packages: +if desc is None: +desc = pkg.short_description +if pkg.binary_package_name.name == self.name: +desc = pkg.short_description +break +except AttributeError: +desc = '' + +return desc + def get_web_package(package_name): diff --git a/distro_tracker/core/templates/core/package.html b/distro_tracker/core/templates/core/package.html index c17f90f..3402eb8 100644 --- a/distro_tracker/core/templates/core/package.html +++ b/distro_tracker/core/templates/core/package.html @@ -16,6 +16,7 @@ /div div class=span6 col col-lg-6 text-center h1{{ package }}/h1 +h4{{ package.short_description }}/h4 /div div class=span3 col col-lg-3 {% include 'core/package-search-form.html' %} diff --git a/distro_tracker/core/tests/tests_models.py b/distro_tracker/core/tests/tests_models.py index da7df4e..50f8e52 100644 --- a/distro_tracker/core/tests/tests_models.py +++ b/distro_tracker/core/tests/tests_models.py @@ -1615,3 +1615,32 @@ class TeamTests(TestCase): self.assertTrue(membership.is_muted(self.package_name)) # The other package isn't self.assertFalse(membership.is_muted(package)) + + +class SourcePackageNameTests(TestCase): + +Tests for the :class:`distro_tracker.core.models.SourcePackageName` model. + +def setUp(self): +self.package = SourcePackageName.objects.create(name='dummy-package') +self.binary_package = BinaryPackageName.objects.create( +name='binary-package') +self.pseudo_package = \ +PseudoPackageName.objects.create(name='pseudo-pkg') +src_pkg = SourcePackage.objects.create( +source_package_name=self.package, version='1.0.0') +bin_pkg = BinaryPackage.objects.create( +binary_package_name=self.binary_package, +source_package=src_pkg, +short_description='a useful package') +src_pkg.binary_packages = [self.binary_package] +src_pkg.save() +bin_pkg.save() + +def test_get_short_description_for_source_pkg(self): +self.assertEqual(self.package.short_description(), 'a useful package') + +def test_get_short_description_with_no_binary_pkgs(self): +pkg = SourcePackageName.objects.create(name='some-package') + +self.assertEqual(pkg.short_description(), '') diff --git
Bug#754658: please display the package's description
The attached patch adds the short description under the source package name. The current PTS only uses the short description if there is a binary package that has the same name as the source package. If not, it just displays Source package I have decided to fall back to the short description for the first binary package instead. This is done in distro_tracker/core/views.py Let me know if there is a better place. I know that views.py can become a bit of a dumping ground, but I didn't see anywhere that made more sense. Also this should really test both if the names match and if they don't, but for the life of me I can't figure out how to get that working in the test suite. I was trying something like: def test_short_desc_on_page_when_same(self): Tests that the short description is displayed when the source package and binary package have the same name. package = SourcePackageName.objects.create(name='another-package') src_pkg = SourcePackage.objects.create( source_package_name=package, version='2.0.0') binary_package = BinaryPackageName.objects.create( name='another-package') bin_pkg = BinaryPackage.objects.create( binary_package_name=binary_package, source_package=src_pkg, short_description='another useful package') src_pkg.binary_packages = [binary_package] src_pkg.save() url = self.get_package_url(self.package.name) response = self.client.get(url) response_content = response.content.decode('utf-8') self.assertIn('another useful package', response_content) Which fails with: IntegrityError: UNIQUE constraint failed: core_packagename.name There must be a way to do it but I'm starting to get a bit frustrated, so I figured I'd just ask. =) Thanks, -- Andrew Starr-Bochicchio Ubuntu Developer https://launchpad.net/~andrewsomething Debian Developer http://qa.debian.org/developer.php?login=asb PGP/GPG Key ID: D53FDCB1 From b2b7261a0f04e2ebc3ea6313def4f912515d5002 Mon Sep 17 00:00:00 2001 From: Andrew Starr-Bochicchio a.star...@gmail.com Date: Fri, 29 Aug 2014 13:05:03 -0700 Subject: [PATCH 2/2] Add the short description under the source package name. The current PTS only uses the short description if there is a binary package that has the same name as the source package. If not, it just displays Source package I have decided to fall back to the short description for the first binary package instead. --- distro_tracker/core/tests/tests_views.py | 18 -- distro_tracker/core/views.py | 12 +++- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/distro_tracker/core/tests/tests_views.py b/distro_tracker/core/tests/tests_views.py index efa2580..957b19a 100644 --- a/distro_tracker/core/tests/tests_views.py +++ b/distro_tracker/core/tests/tests_views.py @@ -16,9 +16,9 @@ Tests for the Distro Tracker core views. from __future__ import unicode_literals from distro_tracker.test import TestCase from django.test.utils import override_settings -from distro_tracker.core.models import PackageName, BinaryPackageName +from distro_tracker.core.models import BinaryPackage, BinaryPackageName from distro_tracker.core.models import SourcePackageName, SourcePackage -from distro_tracker.core.models import PseudoPackageName +from distro_tracker.core.models import PackageName, PseudoPackageName from distro_tracker.core.models import ActionItem, ActionItemType import json @@ -39,6 +39,10 @@ class PackageViewTest(TestCase): self.pseudo_package = PseudoPackageName.objects.create(name='pseudo-pkg') src_pkg = SourcePackage.objects.create( source_package_name=self.package, version='1.0.0') +bin_pkg = BinaryPackage.objects.create( +binary_package_name=self.binary_package, +source_package=src_pkg, +short_description='a useful package') src_pkg.binary_packages = [self.binary_package] src_pkg.save() @@ -163,6 +167,16 @@ class PackageViewTest(TestCase): response = self.client.get(url, follow=True) self.assertEqual(404, response.status_code) +def test_short_desc_on_page(self): + +Tests that the short description is displayed. + +url = self.get_package_url(self.package.name) +response = self.client.get(url) +response_content = response.content.decode('utf-8') + +self.assertIn('a useful package', response_content) + class PackageSearchViewTest(TestCase): def setUp(self): diff --git a/distro_tracker/core/views.py b/distro_tracker/core/views.py index 4876575..597062c 100644 --- a/distro_tracker/core/views.py +++ b/distro_tracker/core/views.py @@ -29,7 +29,7 @@ from distro_tracker.core.models import get_web_package from distro_tracker.core.forms import CreateTeamForm from distro_tracker.core.forms import AddTeamMemberForm
Bug#754658: please display the package's description
Hi, On Fri, 29 Aug 2014, Andrew Starr-Bochicchio wrote: This is done in distro_tracker/core/views.py Let me know if there is a better place. I know that views.py can become a bit of a dumping ground, but I didn't see anywhere that made more sense. It should probably be a method of PackageName so that we get the short description for free in any other context... for example in the mail bot when we confirm the subscription or something like that. Also this should really test both if the names match and if they don't, but for the life of me I can't figure out how to get that working in the test suite. I was trying something like: def test_short_desc_on_page_when_same(self): Tests that the short description is displayed when the source package and binary package have the same name. package = SourcePackageName.objects.create(name='another-package') src_pkg = SourcePackage.objects.create( source_package_name=package, version='2.0.0') binary_package = BinaryPackageName.objects.create( name='another-package') bin_pkg = BinaryPackage.objects.create( binary_package_name=binary_package, source_package=src_pkg, short_description='another useful package') src_pkg.binary_packages = [binary_package] src_pkg.save() Use .get_or_create() instead of create and it will work. SourcePackageName and BinaryPackageName are proxy models of PackageName so they share the same database table and you can't create it twice... the second .get_or_create() will actually do a .get() + a small update to mark the name as a name of a binary package too... There must be a way to do it but I'm starting to get a bit frustrated, so I figured I'd just ask. =) Sure! :) Some comments: - add a test to ensure that it works also when the database doesn't contain any information about binary packages (it's quite possible to configure distro-tracker that way) - please rebase the patch on top of the latest git version, there was quite a bit of churn due to stylistich changes... - make sure you can run tox without failures (I run it on a sid-based system, but jessie will do as well) +try: +bin_pkg = BinaryPackage.objects.filter(binary_package_name=package) +desc = bin_pkg.first().short_description +except AttributeError: +source = SourcePackage.objects.filter(source_package_name=package) +bin_pkg_name = source.last().binary_packages.first() +bin_pkg = BinaryPackage.objects.filter(binary_package_name=bin_pkg_name) +desc = bin_pkg.first().short_description As per-comment above, it will likely fail if there are no binary packages in the database. Also it would be nice if this could be written in a way that doesn't generate a new SQL request but instead relies on attributes of package (that should be prefetched when we fetch that object). https://docs.djangoproject.com/en/1.7/ref/models/querysets/#prefetch-related (The whole webpage is highly non-optimized and peeks at something like 58 SQL requests! We should get that down to less than 10 IMO.) return render(request, 'core/package.html', { 'package': package, +'short_description': desc, 'panels': get_panels_for_package(package, request), 'is_subscribed': is_subscribed, }) If we use a method of package, then you don't have to inject it here. Cheers, -- Raphaël Hertzog ◈ Debian Developer Discover the Debian Administrator's Handbook: → http://debian-handbook.info/get/ -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Bug#754658: please display the package's description
On Fri, Aug 29, 2014 at 2:39 PM, Raphael Hertzog hert...@debian.org wrote: Hi, On Fri, 29 Aug 2014, Andrew Starr-Bochicchio wrote: This is done in distro_tracker/core/views.py Let me know if there is a better place. I know that views.py can become a bit of a dumping ground, but I didn't see anywhere that made more sense. It should probably be a method of PackageName so that we get the short description for free in any other context... for example in the mail bot when we confirm the subscription or something like that. Makes sense. I think I've addressed all the other issues as well. Thanks for the review! -- Andrew Starr-Bochicchio Ubuntu Developer https://launchpad.net/~andrewsomething Debian Developer http://qa.debian.org/developer.php?login=asb PGP/GPG Key ID: D53FDCB1 From e8a3c78471190aca2a04a12100e075fe86ff869b Mon Sep 17 00:00:00 2001 From: Andrew Starr-Bochicchio a.star...@gmail.com Date: Fri, 29 Aug 2014 13:05:03 -0700 Subject: [PATCH] Add the short description under the source package name. The current PTS only uses the short description if there is a binary package that has the same name as the source package. If not, it just displays Source package I have decided to fall back to the short description for the first binary package instead. --- distro_tracker/core/models.py | 23 + distro_tracker/core/templates/core/package.html | 1 + distro_tracker/core/tests/tests_models.py | 33 +++ distro_tracker/core/tests/tests_views.py| 44 +++-- 4 files changed, 99 insertions(+), 2 deletions(-) diff --git a/distro_tracker/core/models.py b/distro_tracker/core/models.py index 2a16944..818fb36 100644 --- a/distro_tracker/core/models.py +++ b/distro_tracker/core/models.py @@ -306,6 +306,29 @@ class PackageName(models.Model): else: super(self, PackageName).delete(*args, **kwargs) +def short_description(self): + +Returns the most recent short description for a package. If there is +a binary package whose name matches the source package, its description +will be used. If not, the short description for the first binary package +will be used. + +If there are no binary packages to get the description from it returns +blank. + +try: +bin_pkg = BinaryPackage.objects.filter(binary_package_name=self) +return bin_pkg.first().short_description +except AttributeError: +try: +source = SourcePackage.objects.filter( +source_package_name=self).prefetch_related( +'binary_packages') +bin_pkg = source.last().binarypackage_set.first() +return bin_pkg.short_description +except AttributeError: +return '' + class PseudoPackageName(PackageName): diff --git a/distro_tracker/core/templates/core/package.html b/distro_tracker/core/templates/core/package.html index c17f90f..3402eb8 100644 --- a/distro_tracker/core/templates/core/package.html +++ b/distro_tracker/core/templates/core/package.html @@ -16,6 +16,7 @@ /div div class=span6 col col-lg-6 text-center h1{{ package }}/h1 +h4{{ package.short_description }}/h4 /div div class=span3 col col-lg-3 {% include 'core/package-search-form.html' %} diff --git a/distro_tracker/core/tests/tests_models.py b/distro_tracker/core/tests/tests_models.py index da7df4e..d16359a 100644 --- a/distro_tracker/core/tests/tests_models.py +++ b/distro_tracker/core/tests/tests_models.py @@ -1615,3 +1615,36 @@ class TeamTests(TestCase): self.assertTrue(membership.is_muted(self.package_name)) # The other package isn't self.assertFalse(membership.is_muted(package)) + + +class PackageNameTests(TestCase): + +Tests for the :class:`distro_tracker.core.models.PackageName` model. + +def setUp(self): +self.package = SourcePackageName.objects.create(name='dummy-package') +self.binary_package = BinaryPackageName.objects.create( +name='binary-package') +self.pseudo_package = \ +PseudoPackageName.objects.create(name='pseudo-pkg') +src_pkg = SourcePackage.objects.create( +source_package_name=self.package, version='1.0.0') +bin_pkg = BinaryPackage.objects.create( +binary_package_name=self.binary_package, +source_package=src_pkg, +short_description='a useful package') +src_pkg.binary_packages = [self.binary_package] +src_pkg.save() +bin_pkg.save() + +def test_get_short_description_for_source_pkg(self): +self.assertEqual(self.package.short_description(), 'a useful package') + +def test_get_short_description_for_binary_pkg(self): +