Merge lp:~jcsackett/launchpad/archivemirror-timeout-618400 into lp:launchpad
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | j.c.sackett | ||||
Approved revision: | no longer in the source branch. | ||||
Merged at revision: | 12235 | ||||
Proposed branch: | lp:~jcsackett/launchpad/archivemirror-timeout-618400 | ||||
Merge into: | lp:launchpad | ||||
Diff against target: |
187 lines (+80/-23) 5 files modified
lib/lp/registry/browser/distribution.py (+9/-2) lib/lp/registry/browser/tests/distribution-views.txt (+16/-0) lib/lp/registry/interfaces/distribution.py (+8/-0) lib/lp/registry/model/distribution.py (+39/-18) lib/lp/registry/model/distributionmirror.py (+8/-3) |
||||
To merge this branch: | bzr merge lp:~jcsackett/launchpad/archivemirror-timeout-618400 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Robert Collins (community) | Approve | ||
Review via email: mp+46550@code.launchpad.net |
Commit message
[r=lifeless]
Description of the change
Summary
=======
Distribution:
This branch addresses the first cause; a second branch will need to be landed to address the second cause and close bug 618400.
In the process there is a slight refactor to remove some repeated code.
Proposed fix
============
When getting distribution mirrors, get the countries for the mirrors at the same time, rather than querying for them one by one later.
Preimplementation
=================
Spoke with Curtis Hovey and William Grant about the country query issue.
Implementation
==============
lib/lp/
lib/lp/
-------
Added a method, _getActiveMirrors, which can generate the resultset for either cdimages or archive mirrors, with or without the country join. Updated the archive_mirrors and cdimage_mirrors properties to use this method. Added an archive_
lib/lp/
-------
Updated the +archivemirrors view and +cdmirrors view to use their respective _by_country property. Updated the parent view to use the returned data properly.
lib/lp/
-------
Drive by reformat of the __all__ clause per style guidelines.
lib/lp/
-------
Updated test to include archive mirrors alongside cdimage.
Tests
=====
bin/test -t distribution-
bin/test -t distributionmir
QA
==
Make certain that Distribution:
Lint
====
= Launchpad lint =
Checking for conflicts and issues in changed files.
Linting changed files:
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
./lib/lp/
594: E501 line too long (80 characters)
460: Line exceeds 78 characters.
478: Line exceeds 78 characters.
594: Line exceeds 78 characters.
812: Line exceeds 78 characters.
865: Line exceeds 78 characters.
The above lint errors are from a number of queries (not in this branch) that I think are already hard enough to read without odd wrapping changes.
A few small comments.
Firstly, rather than selecting wider, consider using the pre_iter_hook on DecoratedResultSet.
This trades off redundant data for a second query with less duplication. It's usually a win.
That said, because you're not exposing the ResultSet we don't even need DecoratedResultSet - so we can just do this:
+ mirrors = list(Store. of(self) .find(Distribut ionMirror, ror.distributio n == self.id, ror.content == mirror_ content_ type, ror.enabled == True, ror.status == MirrorStatus. OFFICIAL, ror.official_ candidate == True, of(self) .find(Country, Country.id.is_in(
+ And(
+ DistributionMir
+ DistributionMir
+ DistributionMir
+ DistributionMir
+ DistributionMir
+ )))
+ if not by_country or not mirrors:
+ return mirrors
+ else:
+ list(Store.
+ [mirror.countryID for mirror in mirrors]))
Secondly, the new collections probably want doNotSnapshot on them.
Cheers,
Rob