launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #00341
[Merge] lp:~edwin-grubbs/launchpad/bug-577492-packaging-duplicates into lp:launchpad/devel
Edwin Grubbs has proposed merging lp:~edwin-grubbs/launchpad/bug-577492-packaging-duplicates into lp:launchpad/devel.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
#577492 +needs-packaging lists duplicates
https://bugs.launchpad.net/bugs/577492
Summary
-------
Eliminate duplicates on $distroseries/+packaging page.
Tests
-----
./bin/test -vv -m 'test_distroseries$'
./bin/test -vvt 'xx-show-distroseries-packaging.txt|doc/distroseries.txt'
Demo and Q/A
------------
* Open https://edge.launchpad.net/debian/squeeze/+packaging
* Each sourcepackagename should only appear once in the list.
--
https://code.launchpad.net/~edwin-grubbs/launchpad/bug-577492-packaging-duplicates/+merge/31297
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~edwin-grubbs/launchpad/bug-577492-packaging-duplicates into lp:launchpad/devel.
=== modified file 'lib/lp/registry/model/distroseries.py'
--- lib/lp/registry/model/distroseries.py 2010-07-27 20:59:06 +0000
+++ lib/lp/registry/model/distroseries.py 2010-07-29 15:22:43 +0000
@@ -356,28 +356,36 @@
# We join to SourcePackageName, ProductSeries, and Product to cache
# the objects that are implcitly needed to work with a
# Packaging object.
- # Avoid circular import failures.
joins, conditions = self._current_sourcepackage_joins_and_conditions
- origin = SQL(joins + """
+ # XXX: EdwinGrubbs 2010-07-29 bug=374777
+ # Storm doesn't support DISTINCT ON.
+ origin = SQL('''
+ (
+ SELECT DISTINCT ON (Packaging.id)
+ Packaging.*,
+ spr.component AS spr_component,
+ SourcePackageName.name AS spn_name,
+ total_bug_heat,
+ po_messages
+ FROM %(joins)s
+ WHERE %(conditions)s
+ AND packaging.id IS NOT NULL
+ ) AS Packaging
JOIN ProductSeries
ON Packaging.productseries = ProductSeries.id
JOIN Product
ON ProductSeries.product = Product.id
- """)
- condition = SQL(conditions + "AND packaging.id IS NOT NULL")
- results = IStore(self).using(origin).find(Packaging, condition)
- return results.order_by("""
- (
- CASE WHEN spr.component = 1 THEN 1000 ELSE 0 END
+ ''' % dict(joins=joins, conditions=conditions))
+ return IStore(self).using(origin).find(Packaging).order_by('''
+ (CASE WHEN spr_component = 1 THEN 1000 ELSE 0 END
+ CASE WHEN Product.bugtracker IS NULL
THEN coalesce(total_bug_heat, 10) ELSE 0 END
+ CASE WHEN ProductSeries.translations_autoimport_mode = 1
THEN coalesce(po_messages, 10) ELSE 0 END
- + CASE WHEN ProductSeries.branch IS NULL THEN 500
- ELSE 0 END
- ) DESC,
- SourcePackageName.name ASC
- """)
+ + CASE WHEN ProductSeries.branch IS NULL THEN 500 ELSE 0 END
+ ) DESC,
+ spn_name ASC
+ ''')
@property
def _current_sourcepackage_joins_and_conditions(self):
=== modified file 'lib/lp/registry/tests/test_distroseries.py'
--- lib/lp/registry/tests/test_distroseries.py 2010-07-26 18:23:34 +0000
+++ lib/lp/registry/tests/test_distroseries.py 2010-07-29 15:22:43 +0000
@@ -211,7 +211,13 @@
self.universe_component = component_set['universe']
self.makeSeriesPackage('normal')
self.makeSeriesPackage('translatable', messages=800)
- self.makeSeriesPackage('hot', heat=500)
+ hot_package = self.makeSeriesPackage('hot', heat=500)
+ # Create a second SPPH for 'hot', to verify that duplicates are
+ # eliminated in the queries.
+ self.factory.makeSourcePackagePublishingHistory(
+ sourcepackagename=hot_package.sourcepackagename,
+ distroseries=self.series,
+ component=self.universe_component, section_name='web')
self.makeSeriesPackage('hot-translatable', heat=250, messages=1000)
self.makeSeriesPackage('main', is_main=True)
self.makeSeriesPackage('linked')
@@ -247,6 +253,7 @@
owner=self.user)
removeSecurityProxy(template).messagecount = messages
self.packages[name] = source_package
+ return source_package
def linkPackage(self, name):
product_series = self.factory.makeProductSeries()