Merge lp:~jcsackett/launchpad/convert-sql-627631 into lp:launchpad/db-devel
| Status: | Merged |
|---|---|
| Approved by: | j.c.sackett on 2010-11-16 |
| Approved revision: | no longer in the source branch. |
| Merged at revision: | 9975 |
| Proposed branch: | lp:~jcsackett/launchpad/convert-sql-627631 |
| Merge into: | lp:launchpad/db-devel |
| Prerequisite: | lp:~jcsackett/launchpad/migrate-official-bool-data-627631 |
| Diff against target: |
454 lines (+122/-74) 16 files modified
database/sampledata/current-dev.sql (+1/-1) database/sampledata/current.sql (+4/-4) database/schema/patch-2208-99-0.sql (+0/-36) lib/canonical/launchpad/database/launchpadstatistic.py (+2/-1) lib/lp/answers/doc/questionsets.txt (+18/-2) lib/lp/answers/model/question.py (+7/-4) lib/lp/answers/stories/questions-index.txt (+15/-0) lib/lp/registry/doc/product.txt (+10/-0) lib/lp/registry/doc/projectgroup.txt (+11/-0) lib/lp/registry/model/product.py (+5/-4) lib/lp/registry/model/projectgroup.py (+2/-7) lib/lp/translations/doc/translationsoverview.txt (+18/-0) lib/lp/translations/model/translationsoverview.py (+11/-8) lib/lp/translations/model/translationsperson.py (+0/-3) lib/lp/translations/scripts/translations_to_branch.py (+0/-3) lib/lp/translations/stories/standalone/xx-rosetta-homepage.txt (+18/-1) |
| To merge this branch: | bzr merge lp:~jcsackett/launchpad/convert-sql-627631 |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Edwin Grubbs (community) | code | 2010-11-03 | Approve on 2010-11-03 |
|
Review via email:
|
|||
Commit Message
[r=edwin-
Description of the Change
Summary
=======
There's an ongoing effort to phase out the official_* booleans which indicate how a product/
This branch rectifies that by cleaning up those sections of code to reference the EnumCol, so that we can (if we choose to) drop the official_* code completely.
Proposed fix
============
Replace locations making SqlObject or Storm queries and update them to use the EnumCol and ServiceUsage DBItem.
Preimplementation talk
=======
Spoke with Curtis Hovey (several weeks ago).
Implementation details
=======
As in proposed.
Tests
=====
Because of the number of things that end up effected, most modules need testing. Testing registry alone is a reasonable proxy, but not ideal.
bin/test -m lp.registry.tests
OR
bin/test -m lp.registry
bin/test -m lp.translations
bin/test -m lp.answers
bin/test -t update_stats
Demo & QA
=========
Operation of the various main pages (e.g. +translations, +questions) for a product or distribution shouldn't fail in anyway or appear different; b/c of prior work this change should be invisible.
Lint
====
make lint output:
= Launchpad lint =
Checking for conflicts and issues in changed files.
Linting changed files:
lib/canonical
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
| j.c.sackett (jcsackett) wrote : | # |
On Nov 3, 2010, at 5:56 PM, Edwin Grubbs wrote:
> Review: Approve code
> Hi JC,
>
> This is a nice branch. I have a few comments below. Remember, you can't go on your honeymoon until you land this branch.
>
> -Edwin
>
>
>> === modified file 'lib/lp/
>> --- lib/lp/
>> +++ lib/lp/
>> @@ -680,8 +681,8 @@
>> LEFT OUTER JOIN Distribution ON (
>> Question.
>> WHERE
>> - (Product.
>> - OR Distribution.
>> + (Product.
>
>
> Trailing whitespace.
>
>
>> + OR Distribution.
>> AND Question.
>> current_timestamp -interval '60 days')
>> LIMIT 5000
>> @@ -689,7 +690,8 @@
>> GROUP BY product, distribution
>> ORDER BY question_count DESC
>> LIMIT %s
>> - """ % sqlvalues(limit))
>> + """ % sqlvalues(
>> + ServiceUsage.
>>
>> projects = []
>> product_set = getUtility(
>>
>> === modified file 'lib/lp/
>> --- lib/lp/
>> +++ lib/lp/
>> @@ -185,17 +185,12 @@
>
>
> There is a bunch of trailing whitespace a little further up in this
> file.
Got both of these. It's odd, make lint didn't return this--is it possible for lint to be overcome by big diffs (the branch this depends on has huge sample data changes)?
>> def translatables(
>> """See `IProjectGroup`."""
>> - # XXX j.c.sackett 2010-08-30 bug=627631: Once data migration has
>> - # happened for the usage enums, this sql needs to be updated to
>> - # check for the translations_usage, not official_rosetta. At that
>> - # time it should also be converted to a Storm query and the issue with
>> - # has_translatables resolved.
>
>
>
> Can you fix the problem with has_translatables now?
Yes; I'm pushing up the fix for that too.
>> === modified file 'lib/lp/
>> --- lib/lp/
>> +++ lib/lp/
>> @@ -67,14 +65,16 @@
>> distribution=
>> WHERE category=3 AND
>> (product IS NOT NULL OR distribution IS NOT NULL) AND
>> - (product.
>> - distribution.
>> + (product.
>> + distribution.
>> GROUP BY product.
>> distribution.
>> HAVING SUM...
| j.c.sackett (jcsackett) wrote : | # |
I had to remove the changes from the prerequisite branch, but now the diff seems huge. I've attached a smaller more clear diff.
| Edwin Grubbs (edwin-grubbs) wrote : | # |
Hi JC,
I found a couple of things that should be changed in your incremental diff.
>=== modified file 'lib/lp/
>--- lib/lp/
>+++ lib/lp/
>
> def has_translatabl
> """See `IProjectGroup`."""
>@@ -205,7 +201,7 @@
> # converted to use is_empty but the implementation in storm's
> # sqlobject wrapper is broken.
> # return not self.translatab
It looks like this comment can also be removed now.
>- return self.translatab
>+ return self.translatab
>
> def has_branches(self):
> """ See `IProjectGroup`."""
>
>=== modified file 'lib/lp/
>--- lib/lp/
>+++ lib/lp/
>@@ -306,15 +306,13 @@
>
> self.store = getUtility(
>
>- # XXX j.c.sackett 2010-08-30 bug=627631 Once data migration has
>- # happened for the usage enums, this sql needs to be updated to
>- # check for the translations_usage, not official_rosetta.
> product_join = Join(
> ProductSeries, Product, ProductSeries.
> productseries = self.store.
>- ProductSeries, SQL(
>- "official_rosetta AND translations_branch IS NOT NULL"))
>-
>+ ProductSeries,
>+ AND(
>+ Product.
>+ Product.
You can't use "is not None" for a storm conditional, since python does
not allow that operator to be overridden. Instead use
and storm will be smart enough to change it to "IS NOT NULL".

Hi JC,
This is a nice branch. I have a few comments below. Remember, you can't go on your honeymoon until you land this branch.
-Edwin
>=== modified file 'lib/lp/ answers/ model/question. py' answers/ model/question. py 2010-10-03 15:30:06 +0000 answers/ model/question. py 2010-11-03 21:39:12 +0000 distribution = Distribution.id) official_ answers is True official_ answers is TRUE) answers_ usage = %s
>--- lib/lp/
>+++ lib/lp/
>@@ -680,8 +681,8 @@
> LEFT OUTER JOIN Distribution ON (
> Question.
> WHERE
>- (Product.
>- OR Distribution.
>+ (Product.
Trailing whitespace.
>+ OR Distribution. answers_ usage = %s) datecreated > ( LAUNCHPAD, ServiceUsage. LAUNCHPAD, limit)) IProductSet) registry/ model/projectgr oup.py' registry/ model/projectgr oup.py 2010-11-02 20:10:56 +0000 registry/ model/projectgr oup.py 2010-11-03 21:39:12 +0000
> AND Question.
> current_timestamp -interval '60 days')
> LIMIT 5000
>@@ -689,7 +690,8 @@
> GROUP BY product, distribution
> ORDER BY question_count DESC
> LIMIT %s
>- """ % sqlvalues(limit))
>+ """ % sqlvalues(
>+ ServiceUsage.
>
> projects = []
> product_set = getUtility(
>
>=== modified file 'lib/lp/
>--- lib/lp/
>+++ lib/lp/
>@@ -185,17 +185,12 @@
There is a bunch of trailing whitespace a little further up in this
file.
> def translatables( self):
> """See `IProjectGroup`."""
>- # XXX j.c.sackett 2010-08-30 bug=627631: Once data migration has
>- # happened for the usage enums, this sql needs to be updated to
>- # check for the translations_usage, not official_rosetta. At that
>- # time it should also be converted to a Storm query and the issue with
>- # has_translatables resolved.
Can you fix the problem with has_translatables now?
> return Product.select(''' official_ rosetta = TRUE AND translations_ usage = %s AND product AND productseries = ProductSeries.id LAUNCHPAD) , ['ProductSeries ', 'POTemplate'], translations/ model/translati onsoverview. py' translations/ model/translati onsoverview. py 2010-08-31 23:03:45 +0000 translations/ model/translati onsoverview. py 2010-11-03 21:39:12 +0000 distribution. id official_ rosetta OR official_ rosetta) translations_ usage = %s OR tranlsations_ usage = %s) displayname, product.id,
> Product.project = %s AND
>- Product.
>+ Product.
> Product.id = ProductSeries.
> POTemplate.
>- ''' % sqlvalues(self),
>+ ''' % sqlvalues(self, ServiceUsage.
> clauseTables=
> distinct=True)
>
>
>=== modified file 'lib/lp/
>--- lib/lp/
>+++ lib/lp/
>@@ -67,14 +65,16 @@
> distribution=
> WHERE category=3 AND
> (product IS NOT NULL OR distribution IS NOT NULL) AND
>- (product.
>- distribution.
>+ (product.
>+ distribution.
> GROUP BY product.
...