Merge lp://qastaging/~edwin-grubbs/launchpad/bug-490659-series-timeout into lp://qastaging/launchpad/db-devel
Status: | Merged |
---|---|
Approved by: | Stuart Bishop |
Approved revision: | no longer in the source branch. |
Merged at revision: | 9696 |
Proposed branch: | lp://qastaging/~edwin-grubbs/launchpad/bug-490659-series-timeout |
Merge into: | lp://qastaging/launchpad/db-devel |
Diff against target: |
429 lines (+135/-62) 17 files modified
database/schema/patch-2208-01-0.sql (+9/-0) database/schema/security.cfg (+1/-0) database/schema/trusted.sql (+27/-0) lib/canonical/launchpad/webapp/sorting.py (+3/-2) lib/lp/registry/browser/__init__.py (+1/-1) lib/lp/registry/browser/configure.zcml (+7/-0) lib/lp/registry/browser/productseries.py (+14/-0) lib/lp/registry/browser/tests/productseries-views.txt (+1/-1) lib/lp/registry/browser/tests/test_milestone.py (+1/-1) lib/lp/registry/interfaces/milestone.py (+2/-0) lib/lp/registry/model/milestone.py (+9/-2) lib/lp/registry/model/projectgroup.py (+17/-5) lib/lp/registry/stories/productseries/xx-productseries-series.txt (+2/-2) lib/lp/registry/templates/object-milestones.pt (+2/-2) lib/lp/registry/templates/productseries-detailed-display.pt (+38/-0) lib/lp/registry/templates/productseries-macros.pt (+0/-42) lib/lp/registry/templates/productseries-status.pt (+1/-4) |
To merge this branch: | bzr merge lp://qastaging/~edwin-grubbs/launchpad/bug-490659-series-timeout |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Stuart Bishop (community) | db | Approve | |
Robert Collins (community) | Approve | ||
Brad Crittenden (community) | code | Approve | |
Review via email: mp+32555@code.qastaging.launchpad.net |
Description of the change
Summary
-------
Bug 490659 reports a timeout caused by a project with over 700 releases.
The ProductSeries' milestones and releases attributes both used a python
function to expand the version numbers in the milestone name so that
milestone version numbers such as 1.1, 1.10, and 1.100 would sort
correctly. To avoid loading all 700 releases from the database just to
sort them in python to find the most recent ones, I added the
milestone_
function, so that the sorting can take place in the db. I also added an
index to the Milestone table using this function.
I have never submitted a db function for review before, so I'm sure that
I'm doing something wrong. For some reason, the configuration I added to
security.cfg doesn't seem to have any effect, so I have to run the
following sql on launchpad_
GRANT EXECUTE ON FUNCTION milestone_
Implementation details
-------
Added milestone_
database/
database/
Added __len__ to DecoratedResultSet, so that code expecting the model to
return a list won't blow up on the result set.
lib/
lib/
Changed the productseries detailed-display macro into its own page since
it makes it cleaner to limit the number of milestones and releases in
the view attributes.
lib/
lib/
lib/
lib/
lib/
Converted HasMilestones' milestones and releases attributes to return a
DecoratedResultSet instead of alist.
lib/
lib/
Tests
-----
./bin/test -vv -t 'xx-productseri
Demo and Q/A
------------
Create a bunch of sample milestones and releases on launchpad.dev:
INSERT INTO Milestone (name, product, productseries)
SELECT 'a' || i, (select id from product where name = 'bzr'),
(select id from productseries where name='trunk' and product = (
FROM generate_series(1, 100) as i;
INSERT INTO Milestone (name, product, productseries, active)
SELECT
'rel-' || i,
(select id from product where name = 'bzr'),
(select id from productseries where name='trunk' and product = (
FALSE
FROM generate_series(1, 100) as i;
INSERT INTO ProductRelease (owner, milestone, datereleased)
SELECT 1, id, now()
FROM Milestone
WHERE name ~ 'rel-.*';
* Open http://
* Only 12 milestones and 12 releases should be listed in the gray box
for trunk.
I don't like the __len__ introduction as it blurs the line between lists and resultsets more : and we suffer because the line is blurry already. I realise you probably have a stack of stuff to put on top of this that is doing lens : however I'm worried about the knock on effects of the change : we should do it in IResultSet if we're doing it at all, not piecemeal on DecoratedResultSet. You could use a lazr.delegates to add __len__ just to your specific case (or, and perhaps better?) work up the stack replacing listified stuff with resultset aware code.
Other than that I think this is conceptually fine and an appropriate solution.
I'm a tad rusty on my plpython gotchas, so I'll let Stuart review that for you.