← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~lifeless/launchpad/bug-734642 into lp:launchpad

 

Robert Collins has proposed merging lp:~lifeless/launchpad/bug-734642 into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #734642 in Launchpad itself: "POFile:+translate timeouts"
  https://bugs.launchpad.net/launchpad/+bug/734642

For more details, see:
https://code.launchpad.net/~lifeless/launchpad/bug-734642/+merge/53365

Improve the query used for rosetta translations per experimentation in bug 734642
-- 
https://code.launchpad.net/~lifeless/launchpad/bug-734642/+merge/53365
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~lifeless/launchpad/bug-734642 into lp:launchpad.
=== modified file 'lib/lp/translations/model/potmsgset.py'
--- lib/lp/translations/model/potmsgset.py	2011-03-08 04:56:22 +0000
+++ lib/lp/translations/model/potmsgset.py	2011-03-15 03:37:06 +0000
@@ -414,10 +414,8 @@
                 quote(suggested_languages), in_use_clause))
         query = []
         query.append('(' + ' OR '.join(lang_used) + ')')
-        query.append('TranslationMessage.potmsgset <> %s' % sqlvalues(self))
 
-        query.append('''
-            potmsgset IN (
+        pots = SQL('''pots as (
                 SELECT POTMsgSet.id
                 FROM POTMsgSet
                 JOIN TranslationTemplateItem ON
@@ -425,8 +423,8 @@
                 JOIN SuggestivePOTemplate ON
                     TranslationTemplateItem.potemplate =
                         SuggestivePOTemplate.potemplate
-                WHERE msgid_singular = %s
-            )''' % sqlvalues(self.msgid_singular))
+                WHERE msgid_singular = %s and potmsgset.id <> %s
+            )''' % sqlvalues(self.msgid_singular, self))
 
         # Subquery to find the ids of TranslationMessages that are
         # matching suggestions.
@@ -445,12 +443,12 @@
         ids_query = '''
             SELECT DISTINCT ON (%(msgstrs)s)
                 TranslationMessage.id
-            FROM TranslationMessage
+            FROM TranslationMessage join pots on pots.id=translationmessage.potmsgset
             WHERE %(where)s
             ORDER BY %(msgstrs)s, date_created DESC
             ''' % ids_query_params
 
-        result = IStore(TranslationMessage).find(
+        result = IStore(TranslationMessage).with_(pots).find(
             TranslationMessage,
             TranslationMessage.id.is_in(SQL(ids_query)))