Merge ~cjwatson/launchpad:fix-translations-opening-unapprove into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: bd76d6dbe1aeb025c95445045b2a73774edd5e82
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:fix-translations-opening-unapprove
Merge into: launchpad:master
Diff against target: 49 lines (+19/-1)
1 file modified
scripts/fix-translations-opening.py (+19/-1)
Reviewer Review Type Date Requested Status
William Grant code Approve
Ines Almeida Approve
Review via email: mp+442642@code.launchpad.net

Commit message

fix-translations-opening: Unapprove existing imports

Description of the change

`scripts/fix-translations-opening.py` is run manually in the case where opening translations for a new series is interrupted (usually due to long transactions making it difficult to continue) and leaves translations in an incomplete state.

The last time we did this, in September 2016, we found that we additionally had to set the associated translation import queue entries back from Approved to Needs Review so that `cronscripts/rosetta-approve-imports.py` could process them again (see https://pastebin.canonical.com/164459/). Rather than keeping this solely in folk memory, let's make the `fix-translations-opening` script do that as well.

I'm afraid I don't have a good way to test this short of the real-world run that we're going to need to perform shortly.

To post a comment you must log in.
Revision history for this message
Ines Almeida (ines-almeida) wrote :

Looks good to me

review: Approve
Revision history for this message
William Grant (wgrant) wrote :

Could I convince you to use the enums rather than hardcoding their integer values? That's a big potential footgun and grep-breaker otherwise.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/scripts/fix-translations-opening.py b/scripts/fix-translations-opening.py
index ad30977..10a9741 100755
--- a/scripts/fix-translations-opening.py
+++ b/scripts/fix-translations-opening.py
@@ -1,6 +1,6 @@
1#!/usr/bin/python3 -S1#!/usr/bin/python3 -S
2#2#
3# Copyright 2012-2013 Canonical Ltd. This software is licensed under the3# Copyright 2012-2023 Canonical Ltd. This software is licensed under the
4# GNU Affero General Public License version 3 (see the file LICENSE).4# GNU Affero General Public License version 3 (see the file LICENSE).
55
6import _pythonpath # noqa: F4016import _pythonpath # noqa: F401
@@ -13,6 +13,7 @@ from lp.registry.model.distroseries import DistroSeries
13from lp.services.database.interfaces import IPrimaryStore13from lp.services.database.interfaces import IPrimaryStore
14from lp.services.looptuner import DBLoopTuner, ITunableLoop14from lp.services.looptuner import DBLoopTuner, ITunableLoop
15from lp.services.scripts.base import LaunchpadScript15from lp.services.scripts.base import LaunchpadScript
16from lp.translations.enums import RosettaImportStatus
1617
17delete_pofiletranslator = """\18delete_pofiletranslator = """\
18DELETE FROM POFileTranslator19DELETE FROM POFileTranslator
@@ -87,6 +88,22 @@ DELETE FROM POTemplate
87 LIMIT ?)88 LIMIT ?)
88"""89"""
8990
91# Reset status from Approved to Needs Review; we've just unset the target,
92# so these entries will have to be gardened again.
93unapprove_translationimportqueueentry = """\
94UPDATE TranslationImportQueueEntry
95 SET status = %(needs_review)d
96 WHERE TranslationImportQueueEntry.id IN (
97 SELECT TranslationImportQueueEntry.id
98 FROM TranslationImportQueueEntry
99 WHERE TranslationImportQueueEntry.status = %(approved)d
100 AND TranslationImportQueueEntry.distroseries = ?
101 LIMIT ?)
102""" % {
103 "needs_review": RosettaImportStatus.NEEDS_REVIEW.value,
104 "approved": RosettaImportStatus.APPROVED.value,
105}
106
90statements = [107statements = [
91 delete_pofiletranslator,108 delete_pofiletranslator,
92 null_translationimportqueueentry_pofile,109 null_translationimportqueueentry_pofile,
@@ -95,6 +112,7 @@ statements = [
95 delete_packagingjob,112 delete_packagingjob,
96 null_translationimportqueueentry_potemplate,113 null_translationimportqueueentry_potemplate,
97 delete_potemplate,114 delete_potemplate,
115 unapprove_translationimportqueueentry,
98]116]
99117
100118

Subscribers

People subscribed via source and target branches

to status/vote changes: