Merge lp:~jtv/launchpad/bug-994650-scrub-pofiletranslator into lp:launchpad
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Jeroen T. Vermeulen | ||||
Approved revision: | no longer in the source branch. | ||||
Merge reported by: | Jeroen T. Vermeulen | ||||
Merged at revision: | not available | ||||
Proposed branch: | lp:~jtv/launchpad/bug-994650-scrub-pofiletranslator | ||||
Merge into: | lp:launchpad | ||||
Diff against target: |
423 lines (+385/-0) 4 files modified
database/schema/security.cfg (+1/-0) lib/lp/scripts/garbo.py (+4/-0) lib/lp/translations/scripts/scrub_pofiletranslator.py (+161/-0) lib/lp/translations/scripts/tests/test_scrub_pofiletranslator.py (+219/-0) |
||||
To merge this branch: | bzr merge lp:~jtv/launchpad/bug-994650-scrub-pofiletranslator | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Benji York (community) | code | Approve | |
Review via email: mp+104866@code.launchpad.net |
Commit message
POFileTranslator scrubber script.
Description of the change
This is as discussed on the internal mailing list. In a series of branches that simplifies and streamlines POFileTranslator management, this is the only one that introduces new code. It won't run while we still have POFileTranslato
POFileTranslator is described as an “eager materialized view.” It's a cache of who contributed TranslationMessages to which POFiles, and when they last did.
What you see in this branch is a scrubbing script for POFileTranslator. Instead of trying (and in many ways failing) to maintain that table synchronously using a long and complex database trigger, Launchpad will keep it “eventually consistent” by running this script. The script doesn't care how data got where it is, so some painfully complex script code that updates the table can disappear. Instead, the script just finds out which entries are missing and which ones need adding, and does that.
The script may still need optimizing. I deliberately kept it simple. In the current code it would have been easy to check for and correct timestamps on the contributions as well, but I think that's of secondary importantance. Where we have a justified POFileTranslator record, its timestamp is likely to be correct; the known problems involve records being omitted altogether. And simplifications I'm introducing elsewhere may also cause records to be omitted, or left in place when they should be moved to different POFiles, or deleted.
This branch looks good. Here are a couple of things I spotted
while reading over it.
I believe that this bit is a syntax error in Python 2.6 as dict nslator. py):
comprehensions were added in 2.7. (line 132 of the diff, from
scrub_pofiletra
return {poft.personID: poft for poft in pofts}
Converting it to something like this should work (untested):
return dict((poft. personID, poft) for poft in pofts)
Since you wrap all calls to measure_distance in abs, you could just put
the abs in measure_distance.