Merge lp://staging/~jtv/launchpad/bug-408718 into lp://staging/launchpad

Proposed by Jeroen T. Vermeulen
Status: Merged
Approved by: Brad Crittenden
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp://staging/~jtv/launchpad/bug-408718
Merge into: lp://staging/launchpad
Diff against target: None lines
To merge this branch: bzr merge lp://staging/~jtv/launchpad/bug-408718
Reviewer Review Type Date Requested Status
Brad Crittenden (community) Approve
Review via email: mp+9696@code.staging.launchpad.net
To post a comment you must log in.
Revision history for this message
Jeroen T. Vermeulen (jtv) wrote :

= Bug 408718: a cleanup =

At one point a caching query in the import process was observed to use
far too much temporary-table space on the database server. The query
text was not fully known, since the place it was observed in truncated
it. There is no doubt which query it is, however.

The spike was probably a fluke, but it turns out there are two tables in
the join that needn't be. Might as well take them out and make it that
little bit easier for the admins to see what's going on.

And who knows, it may even help performance a bit. :-)

Test:
{{{
./bin/test -vv -t 'translations.import'
}}}

QA: Perform normal imports on staging. The importer runs as a cron job
there, so no LOSA help needed. Just pick an Imported upload from the
staging import queue and reset it to Approved:

  https://translations.staging.launchpad.net/+imports/+index?field.filter_target=[PRODUCT]&field.filter_status=APPROVED

Then watch it go back to Imported sometime in the next hour or so. Or
if there are none, approve a few Needs Review ones and see that they
either succeed or produce sensible error messages.

No lint complaints.

Jeroen

Revision history for this message
Brad Crittenden (bac) wrote :

Looks good Jeroen. I hope it helps...

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/translations/utilities/translation_import.py'
2--- lib/lp/translations/utilities/translation_import.py 2009-07-17 00:26:05 +0000
3+++ lib/lp/translations/utilities/translation_import.py 2009-08-05 13:11:00 +0000
4@@ -130,6 +130,14 @@
5 "pt%d.translation AS translation%d" % (form, form)
6 for form in xrange(TranslationConstants.MAX_PLURAL_FORMS)]
7
8+ substitutions = {
9+ 'translation_columns': ', '.join(translations),
10+ 'translation_joins': '\n'.join(msgstr_joins),
11+ 'language': quote(self.pofile.language),
12+ 'variant': quote(self.pofile.variant),
13+ 'potemplate': quote(self.pofile.potemplate),
14+ }
15+
16 sql = '''
17 SELECT
18 POMsgId.msgid AS msgid,
19@@ -141,18 +149,14 @@
20 %(translation_columns)s
21 FROM POTMsgSet
22 JOIN TranslationTemplateItem ON
23- TranslationTemplateItem.potmsgset=POTMsgSet.id
24- JOIN POTemplate ON
25- POTemplate.id=TranslationTemplateItem.potemplate
26- JOIN POFile ON
27- POFile.potemplate=POTemplate.id AND
28- POFile.id=%(pofile)s
29+ TranslationTemplateItem.potmsgset = POTMsgSet.id AND
30+ TranslationTemplateItem.potemplate = %(potemplate)s
31 JOIN TranslationMessage ON
32 POTMsgSet.id=TranslationMessage.potmsgset AND
33- (TranslationMessage.potemplate=POTemplate.id OR
34+ (TranslationMessage.potemplate = %(potemplate)s OR
35 TranslationMessage.potemplate IS NULL) AND
36- POFile.language=TranslationMessage.language AND
37- POFile.variant IS NOT DISTINCT FROM TranslationMessage.variant
38+ TranslationMessage.language = %(language)s AND
39+ TranslationMessage.variant IS NOT DISTINCT FROM %(variant)s
40 %(translation_joins)s
41 JOIN POMsgID ON
42 POMsgID.id=POTMsgSet.msgid_singular
43@@ -163,9 +167,7 @@
44 ORDER BY
45 TranslationTemplateItem.sequence,
46 TranslationMessage.potemplate NULLS LAST
47- ''' % { 'translation_columns' : ','.join(translations),
48- 'translation_joins' : '\n'.join(msgstr_joins),
49- 'pofile' : quote(self.pofile) }
50+ ''' % substitutions
51 cur = cursor()
52 cur.execute(sql)
53 rows = cur.fetchall()