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
=== modified file 'lib/lp/translations/doc/translationimportqueue.txt'
--- lib/lp/translations/doc/translationimportqueue.txt 2009-07-23 17:49:31 +0000
+++ lib/lp/translations/doc/translationimportqueue.txt 2009-09-28 09:49:14 +0000
@@ -130,8 +130,12 @@
130 >>> login('carlos@canonical.com')130 >>> login('carlos@canonical.com')
131 >>> entry.setStatus(RosettaImportStatus.IMPORTED)131 >>> entry.setStatus(RosettaImportStatus.IMPORTED)
132132
133Need to update our saved date_status_changed to detect if it changes now.133The status change updates date_status_changed as well.
134134
135 >>> entry.date_status_changed > previous_date_status_changed
136 True
137
138 >>> transaction.commit()
135 >>> previous_date_status_changed = entry.date_status_changed139 >>> previous_date_status_changed = entry.date_status_changed
136140
137Do the new upload. It will be a published upload.141Do the new upload. It will be a published upload.
@@ -144,15 +148,15 @@
144148
145And the new status is149And the new status is
146150
147 >>> po_sr_entry.status.title151 >>> print po_sr_entry.status.title
148 'Needs Review'152 Needs Review
149153
150The dateimported remains the same as it was already waiting to be imported.154The dateimported remains the same as it was already waiting to be imported.
151155
152 >>> po_sr_entry.dateimported > previous_dateimported156 >>> po_sr_entry.dateimported > previous_dateimported
153 True157 True
154158
155And the date_status_changed is newer159However the date_status_changed is still updated.
156160
157 >>> po_sr_entry.date_status_changed > previous_date_status_changed161 >>> po_sr_entry.date_status_changed > previous_date_status_changed
158 True162 True
159163
=== modified file 'lib/lp/translations/model/translationimportqueue.py'
--- lib/lp/translations/model/translationimportqueue.py 2009-09-21 19:31:07 +0000
+++ lib/lp/translations/model/translationimportqueue.py 2009-09-28 09:49:14 +0000
@@ -256,9 +256,8 @@
256256
257 def setStatus(self, status):257 def setStatus(self, status):
258 """See `ITranslationImportQueueEntry`."""258 """See `ITranslationImportQueueEntry`."""
259 # XXX JeroenVermeulen 2009-04-09 bug=358404: This looks like a
260 # good place to set date_status_changed.
261 self.status = status259 self.status = status
260 self.date_status_changed = UTC_NOW
262261
263 def setErrorOutput(self, output):262 def setErrorOutput(self, output):
264 """See `ITranslationImportQueueEntry`."""263 """See `ITranslationImportQueueEntry`."""