Merge lp:~jtv/launchpad/bug-719267 into lp:launchpad
Status: | Merged |
---|---|
Approved by: | Robert Collins |
Approved revision: | no longer in the source branch. |
Merged at revision: | 12425 |
Proposed branch: | lp:~jtv/launchpad/bug-719267 |
Merge into: | lp:launchpad |
Diff against target: |
65 lines (+25/-2) 3 files modified
lib/lp/translations/model/pofile.py (+12/-0) lib/lp/translations/model/potemplate.py (+1/-2) lib/lp/translations/tests/test_pofile.py (+12/-0) |
To merge this branch: | bzr merge lp:~jtv/launchpad/bug-719267 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Robert Collins (community) | Approve | ||
Review via email: mp+50651@code.launchpad.net |
Commit message
[r=lifeless][bug=719267] Fix timeouts on approval of new translations templates.
Description of the change
= Summary =
Timeouts were blocking translations import queue reviews, at least the creation of new templates. The time went into recalculating the statistics of each POFile that is created to match ones in sharing templates. Some large queries are involved.
== Proposed fix ==
A new template is created empty, so there's no need to query the database — all the counts that get constructed directly from the queries are zero.
I considered adding a parameter for "don't bother calculating the statistics," since the problem happens in a known scenario where the statistics don't need calculating. But in the end I just created some shortcuts: if the template is empty, the queries are skipped and zero counts are returned. This doesn't affect any APIs and may even benefit additional invocations.
== Pre-implementation notes ==
Robert looked into optimizing statistics calculation for multiple languages at once. The results are promising, though in this case there's no need to go to the trouble.
== Implementation details ==
The call that led to the unnecessary queries had an unnecessary line break. There is no other reason why I changed it.
== Tests ==
The statistics as calculated by the changed methods are extensively tested by:
{{{
./bin/test -vvc lp.translations
}}}
I'm adding one for the zero case, just in case it's not properly covered: test_updateStat
== Demo and Q/A ==
Approve the oldest translation template uploads awaiting review. The requests should not time out.
Run cronscripts/
= Launchpad lint =
Checking for conflicts and issues in changed files.
Linting changed files:
lib/lp/
lib/lp/