launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #24547
[Merge] ~cjwatson/launchpad:simplify-external-translation-messages into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:simplify-external-translation-messages into launchpad:master.
Commit message:
Simplify POTMsgSet._getExternalTranslationMessages
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
Bug #736005 in Launchpad itself: "POFile:+translate timeouts"
https://bugs.launchpad.net/launchpad/+bug/736005
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/381540
There's no obvious point to sorting the results of a subquery and then passing it straight to the IN operator; this seems to be a vestige of earlier code that fetched the result of the subquery into Python. This doesn't seem to make a massive difference (though it's a bit hard to tell due to caching), but it at least simplifies the query plan.
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:simplify-external-translation-messages into launchpad:master.
diff --git a/lib/lp/translations/model/potmsgset.py b/lib/lp/translations/model/potmsgset.py
index 12f9f05..4895840 100644
--- a/lib/lp/translations/model/potmsgset.py
+++ b/lib/lp/translations/model/potmsgset.py
@@ -419,25 +419,14 @@ class POTMsgSet(SQLBase):
# Subquery to find the ids of TranslationMessages that are
# matching suggestions.
- # We're going to get a lot of duplicates, sometimes resulting in
- # thousands of suggestions. Weed out most of that duplication by
- # excluding older messages that are identical to newer ones in
- # all translated forms. The Python code can later sort out the
- # distinct translations per form.
- msgstrs = ', '.join([
- 'COALESCE(msgstr%d, -1)' % form
- for form in range(TranslationConstants.MAX_PLURAL_FORMS)])
ids_query_params = {
- 'msgstrs': msgstrs,
'where': '(' + ' OR '.join(lang_used) + ')',
}
ids_query = '''
- SELECT DISTINCT ON (%(msgstrs)s)
- TranslationMessage.id
+ SELECT TranslationMessage.id
FROM TranslationMessage
JOIN msgsets ON msgsets.id = TranslationMessage.potmsgset
WHERE %(where)s
- ORDER BY %(msgstrs)s, date_created DESC
''' % ids_query_params
result = IStore(TranslationMessage).with_(msgsets).find(