Merge lp:~lifeless/launchpad/registry-packagings into lp:launchpad

Proposed by Robert Collins
Status: Merged
Approved by: Curtis Hovey
Approved revision: no longer in the source branch.
Merged at revision: 11317
Proposed branch: lp:~lifeless/launchpad/registry-packagings
Merge into: lp:launchpad
Diff against target: 86 lines (+23/-9)
3 files modified
lib/lp/registry/browser/distroseries.py (+1/-1)
lib/lp/registry/doc/distroseries.txt (+1/-1)
lib/lp/registry/model/distroseries.py (+21/-7)
To merge this branch: bzr merge lp:~lifeless/launchpad/registry-packagings
Reviewer Review Type Date Requested Status
Robert Collins (community) release-critical Approve
Curtis Hovey (community) Approve
Julian Edwards release-manager Pending
Review via email: mp+32164@code.launchpad.net

Commit message

Change listified packagings into DecoratedResultSets to allow count() without deserialising thousands of objects.

Description of the change

Help address a high frequency timeout, bug 612358.

This probably is RC, as IIRC its an edge specific issue at the moment.

To post a comment you must log in.
Revision history for this message
Curtis Hovey (sinzui) wrote :

Thanks for working this issue out with me. This looks good to land.

review: Approve
Revision history for this message
Robert Collins (lifeless) wrote :

Using my own rc stamp after discussion with Curtis.

review: Approve (release-critical)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/registry/browser/distroseries.py'
--- lib/lp/registry/browser/distroseries.py 2010-08-06 12:49:27 +0000
+++ lib/lp/registry/browser/distroseries.py 2010-08-10 03:04:59 +0000
@@ -317,7 +317,7 @@
317 @cachedproperty317 @cachedproperty
318 def num_linked_packages(self):318 def num_linked_packages(self):
319 """The number of linked packagings for this distroseries."""319 """The number of linked packagings for this distroseries."""
320 return len(self.context.packagings)320 return self.context.packagings.count()
321321
322 @property322 @property
323 def num_unlinked_packages(self):323 def num_unlinked_packages(self):
324324
=== modified file 'lib/lp/registry/doc/distroseries.txt'
--- lib/lp/registry/doc/distroseries.txt 2010-07-28 02:02:25 +0000
+++ lib/lp/registry/doc/distroseries.txt 2010-08-10 03:04:59 +0000
@@ -479,7 +479,7 @@
479 >>> distribution = factory.makeDistribution()479 >>> distribution = factory.makeDistribution()
480 >>> distroseries = factory.makeDistroRelease(distribution=distribution)480 >>> distroseries = factory.makeDistroRelease(distribution=distribution)
481 >>> pkgs = distroseries.getMostRecentlyLinkedPackagings()481 >>> pkgs = distroseries.getMostRecentlyLinkedPackagings()
482 >>> print len(pkgs)482 >>> print pkgs.count()
483 0483 0
484484
485 >>> for name in ['aaron', 'bjorn', 'chex', 'deryck', 'edwin', 'francis']:485 >>> for name in ['aaron', 'bjorn', 'chex', 'deryck', 'edwin', 'francis']:
486486
=== modified file 'lib/lp/registry/model/distroseries.py'
--- lib/lp/registry/model/distroseries.py 2010-08-02 02:13:52 +0000
+++ lib/lp/registry/model/distroseries.py 2010-08-10 03:04:59 +0000
@@ -286,10 +286,20 @@
286286
287 @cachedproperty287 @cachedproperty
288 def _all_packagings(self):288 def _all_packagings(self):
289 """Get an unordered list of all packagings."""289 """Get an unordered list of all packagings.
290
291 :return: A ResultSet which can be decorated or tuned further. Use
292 DistroSeries._packaging_row_to_packaging to extract the
293 packaging objects out.
294 """
290 # We join to SourcePackageName, ProductSeries, and Product to cache295 # We join to SourcePackageName, ProductSeries, and Product to cache
291 # the objects that are implicitly needed to work with a296 # the objects that are implicitly needed to work with a
292 # Packaging object.297 # Packaging object.
298 # NB: precaching objects like this method tries to do has a very poor
299 # hit rate with storm - many queries will still be executed; consider
300 # ripping this out and instead allowing explicit inclusion of things
301 # like Person._all_members does - returning a cached object graph.
302 # -- RBC 20100810
293 # Avoid circular import failures.303 # Avoid circular import failures.
294 from lp.registry.model.product import Product304 from lp.registry.model.product import Product
295 from lp.registry.model.productseries import ProductSeries305 from lp.registry.model.productseries import ProductSeries
@@ -309,14 +319,19 @@
309 results = IStore(self).using(*origin).find(find_spec, condition)319 results = IStore(self).using(*origin).find(find_spec, condition)
310 return results320 return results
311321
322 @staticmethod
323 def _packaging_row_to_packaging(row):
324 # each row has:
325 # (packaging, spn, product_series, product)
326 return row[0]
327
312 @property328 @property
313 def packagings(self):329 def packagings(self):
314 """See `IDistroSeries`."""330 """See `IDistroSeries`."""
315 results = self._all_packagings331 results = self._all_packagings
316 results = results.order_by(SourcePackageName.name)332 results = results.order_by(SourcePackageName.name)
317 return [333 return DecoratedResultSet(results,
318 packaging334 DistroSeries._packaging_row_to_packaging)
319 for (packaging, spn, product_series, product) in results]
320335
321 def getPrioritizedUnlinkedSourcePackages(self):336 def getPrioritizedUnlinkedSourcePackages(self):
322 """See `IDistroSeries`.337 """See `IDistroSeries`.
@@ -454,9 +469,8 @@
454 # identical creation dates.469 # identical creation dates.
455 results = results.order_by(Desc(Packaging.datecreated),470 results = results.order_by(Desc(Packaging.datecreated),
456 SourcePackageName.name)[:5]471 SourcePackageName.name)[:5]
457 return [472 return DecoratedResultSet(results,
458 packaging473 DistroSeries._packaging_row_to_packaging)
459 for (packaging, spn, product_series, product) in results]
460474
461 @property475 @property
462 def supported(self):476 def supported(self):