Merge lp:~jtv/launchpad/bug-358404 into lp:launchpad

Proposed by Jeroen T. Vermeulen
Status: Merged
Approved by: Jeroen T. Vermeulen
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~jtv/launchpad/bug-358404
Merge into: lp:launchpad
Diff against target: 52 lines
2 files modified
lib/lp/translations/doc/translationimportqueue.txt (+9/-5)
lib/lp/translations/model/translationimportqueue.py (+1/-2)
To merge this branch: bzr merge lp:~jtv/launchpad/bug-358404
Reviewer Review Type Date Requested Status
Eleanor Berger (community) Approve
Review via email: mp+12430@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Jeroen T. Vermeulen (jtv) wrote :

= Bug 358404 =

This bug just rose in relevance after an unknown number of Translations
import queue entries got approved for import into the wrong templates.
We found out about the problem within hours, and it would have been easy
to identify the exact queue entries that had the problem. But because
the "date_status_changed" property on the entries was not updated during
approval or import, and because the entries were old, the cleanup that
was supposed to have removed them 3 days after import deleted them
instantly instead.

Here's a branch to change that. We had already isolated the setting of
an entry's status into a setStatus method (mostly to simplify API work),
and that is the perfect place to update the date_status_changed as well.

One test was updated very slightly. The reason is relatively complex:
two of these dates were being compared, but the one that was supposed to
be further into the past is getting an extra "refresh" from this change.
In addition, the timestamp used is the beginning of the current database
transaction. Consequently the clock doesn't advance between actions in
the same transaction, and this contributed to the "older" date not being
further in the past than the "newer" one.

I fixed this with an extra commit, and took the opportunity to add a
check around just the setStatus() call.

Tests:
{{{
./bin/test -vv -t translationimportqueue
}}}

For Q/A, pick an entry on the import queue (/+imports) that is at least
3 days old, and is in a Needs Review state. Approve it. Wait for the
import to occur (watch it go to Imported, which means it should be
cleaned up after three days), and then wait for an hour or two more to
let the cleanup process run. Or if we're talking launchpad.dev, import
the file by running the rosetta-poimport.py cron job; and then run
rosetta-approve-imports.py to execute the cleanup.

The cleanup will clean up the entry 3 days after the import attempt,
not 3 days after the upload.

No lint.

Jeroen

Revision history for this message
Eleanor Berger (intellectronica) :
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/doc/translationimportqueue.txt'
2--- lib/lp/translations/doc/translationimportqueue.txt 2009-07-23 17:49:31 +0000
3+++ lib/lp/translations/doc/translationimportqueue.txt 2009-09-28 09:49:14 +0000
4@@ -130,8 +130,12 @@
5 >>> login('carlos@canonical.com')
6 >>> entry.setStatus(RosettaImportStatus.IMPORTED)
7
8-Need to update our saved date_status_changed to detect if it changes now.
9-
10+The status change updates date_status_changed as well.
11+
12+ >>> entry.date_status_changed > previous_date_status_changed
13+ True
14+
15+ >>> transaction.commit()
16 >>> previous_date_status_changed = entry.date_status_changed
17
18 Do the new upload. It will be a published upload.
19@@ -144,15 +148,15 @@
20
21 And the new status is
22
23- >>> po_sr_entry.status.title
24- 'Needs Review'
25+ >>> print po_sr_entry.status.title
26+ Needs Review
27
28 The dateimported remains the same as it was already waiting to be imported.
29
30 >>> po_sr_entry.dateimported > previous_dateimported
31 True
32
33-And the date_status_changed is newer
34+However the date_status_changed is still updated.
35
36 >>> po_sr_entry.date_status_changed > previous_date_status_changed
37 True
38
39=== modified file 'lib/lp/translations/model/translationimportqueue.py'
40--- lib/lp/translations/model/translationimportqueue.py 2009-09-21 19:31:07 +0000
41+++ lib/lp/translations/model/translationimportqueue.py 2009-09-28 09:49:14 +0000
42@@ -256,9 +256,8 @@
43
44 def setStatus(self, status):
45 """See `ITranslationImportQueueEntry`."""
46- # XXX JeroenVermeulen 2009-04-09 bug=358404: This looks like a
47- # good place to set date_status_changed.
48 self.status = status
49+ self.date_status_changed = UTC_NOW
50
51 def setErrorOutput(self, output):
52 """See `ITranslationImportQueueEntry`."""