Merge lp:~danilo/launchpad/bug-414832 into lp:launchpad

Proposed by Данило Шеган
Status: Merged
Merged at revision: not available
Proposed branch: lp:~danilo/launchpad/bug-414832
Merge into: lp:launchpad
Diff against target: None lines
To merge this branch: bzr merge lp:~danilo/launchpad/bug-414832
Reviewer Review Type Date Requested Status
Henning Eggers (community) Approve
Review via email: mp+10256@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Данило Шеган (danilo) wrote :

= Bug #414832 =

I've used a silly little clause that reduces duplicate rows in SQL when
doing symmetric joins of the same table twice. However, Jeroen rightly
noted how this is not the right thing to do here, so here's a fix.

Note that this code has not rolled out to production yet, so I can
thank Jeroen for catching this so early even before the QA.

== Proposed fix ==

Remove "other.id >= this.id" clause from SQL.

== Tests ==

bin/test -vvt getPOFilesTouchedSince_bug_414832

(I didn't want to bother to figure out a better name for the test,
since the test is basically what it is; it's very dependent on the
previous broken implementation).

== Demo and Q/A ==

Test

  cronscripts/rosetta-pofile-stats-daily.py

on staging.

= Launchpad lint =

Checking for conflicts. and issues in doctests and templates.
Running jslint, xmllint, pyflakes, and pylint.
Using normal rules.

Linting changed files:
  lib/lp/translations/tests/test_pofile.py
  lib/lp/translations/model/pofile.py

Revision history for this message
Henning Eggers (henninge) wrote :

With test rename as discussed.

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/model/pofile.py'
2--- lib/lp/translations/model/pofile.py 2009-08-07 17:58:19 +0000
3+++ lib/lp/translations/model/pofile.py 2009-08-17 15:20:16 +0000
4@@ -1584,8 +1584,7 @@
5 # and its ProductSeries and DistroSeries, if they are defined.
6 OtherPOT = ClassAlias(POTemplate)
7 OtherPOTJoin = Join(
8- OtherPOT, And(OtherPOT.name == MatchingPOT.name,
9- OtherPOT.id >= MatchingPOT.id))
10+ OtherPOT, And(OtherPOT.name == MatchingPOT.name))
11 OtherProductSeries = ClassAlias(ProductSeries)
12 OtherProductSeriesJoin = LeftJoin(
13 OtherProductSeries,
14
15=== modified file 'lib/lp/translations/tests/test_pofile.py'
16--- lib/lp/translations/tests/test_pofile.py 2009-08-07 17:58:19 +0000
17+++ lib/lp/translations/tests/test_pofile.py 2009-08-17 15:20:16 +0000
18@@ -1194,6 +1194,32 @@
19 pofiles = self.pofileset.getPOFilesTouchedSince(yesterday)
20 self.assertContentEqual([pofile1, pofile2], pofiles)
21
22+ def test_POFileSet_getPOFilesTouchedSince_bug_414832(self):
23+ # Make sure that all relevant POFiles are returned,
24+ # even the sharing ones with smaller IDs.
25+ product = self.factory.makeProduct()
26+ product.official_rosetta = True
27+ series1 = self.factory.makeProductSeries(product=product,
28+ name='one')
29+ series2 = self.factory.makeProductSeries(product=product,
30+ name='two')
31+ potemplate1 = self.factory.makePOTemplate(name='shared',
32+ productseries=series1)
33+ pofile1 = self.factory.makePOFile('sr', potemplate=potemplate1)
34+ potemplate2 = self.factory.makePOTemplate(name='shared',
35+ productseries=series2)
36+ pofile2 = potemplate2.getPOFileByLang('sr')
37+ now = datetime.now(pytz.UTC)
38+ yesterday = now - timedelta(1)
39+ week_ago = now - timedelta(7)
40+ pofile1.date_changed = week_ago
41+
42+ # Let's make sure the condition from the bug holds,
43+ # since pofile2 is created implicitely with the makePOTemplate call.
44+ self.assertTrue(pofile1.id < pofile2.id)
45+ pofiles = self.pofileset.getPOFilesTouchedSince(yesterday)
46+ self.assertContentEqual([pofile1, pofile2], pofiles)
47+
48 def test_POFileSet_getPOFilesTouchedSince_shared_in_distribution(self):
49 # Make sure actual touched POFiles and POFiles that are sharing
50 # with them in the same distribution/sourcepackage are all returned
51