Merge lp://staging/~adeuring/launchpad/bug-768443 into lp://staging/launchpad

Proposed by Abel Deuring
Status: Merged
Approved by: Abel Deuring
Approved revision: no longer in the source branch.
Merged at revision: 12965
Proposed branch: lp://staging/~adeuring/launchpad/bug-768443
Merge into: lp://staging/launchpad
Diff against target: 171 lines (+81/-4)
5 files modified
lib/lp/bugs/browser/structuralsubscription.py (+2/-2)
lib/lp/bugs/browser/tests/test_expose.py (+60/-1)
lib/lp/registry/interfaces/person.py (+3/-0)
lib/lp/registry/model/person.py (+4/-0)
lib/lp/registry/tests/test_person.py (+12/-1)
To merge this branch: bzr merge lp://staging/~adeuring/launchpad/bug-768443
Reviewer Review Type Date Requested Status
Graham Binns (community) code Approve
Review via email: mp+59782@code.staging.launchpad.net

Commit message

[r=gmb][bug=768443] new cached property Person.administrated_teams; Person.administrated_teams used in lp.bugs.browser.structuralsubscription.expose_.*_to_js() in order to avoid multiple calls of Person.getAdministratedTeams()

Description of the change

This branch fixes bug 768443: ProductSeries:+index timeout with many releases

The reason for the timeout are many calls of Person.getAdministratedTeams() in lp.bugs.browser.structuralsubscription.expose_user_administered_teams_to_js() and lp.bugs.browser.structuralsubscription.expose_user_subscriptions_to_js()

These functions are called in lp.registry.browser.productseries.ProductSeriesView.initiakize() and in lp.registry.browser.milestone.MilestoneView.initialize()

One OOPS had more than 90 calls of getAdministratedTeams(); with an "SQL time" of 80..200msec per call this is an obvious cause for the timeouts.

At first I intended to cache the query result inside Person.getAdministratedTeams() but got scared when I noticed that this method is also used in security.py -- if the affected checkAuthenticated() method is called in a method where team memberships are changed, we might end with an invalid permission check, so I added the somewhat redundant cached property Person.adminstrated_teams which is now used in the affected functions expose_.*_to_js()

tests:

./bin/test bugs -vvt test_expose
./bin/test registry -vvt test_person.TestPersonTeams

no lint

To post a comment you must log in.
Revision history for this message
Graham Binns (gmb) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.