Code review comment for lp:~jcsackett/launchpad/convert-sql-627631
- convert-sql-627631
- Merge into db-devel
Revision history for this message
j.c.sackett (jcsackett) wrote : | # |
1 | === modified file 'lib/canonical/launchpad/database/launchpadstatistic.py' |
2 | --- lib/canonical/launchpad/database/launchpadstatistic.py 2010-10-03 15:30:06 +0000 |
3 | +++ lib/canonical/launchpad/database/launchpadstatistic.py 2010-11-03 17:58:38 +0000 |
4 | @@ -32,6 +32,7 @@ |
5 | QuestionStatus, |
6 | ) |
7 | from lp.answers.model.question import Question |
8 | +from lp.app.enums import ServiceUsage |
9 | from lp.bugs.model.bug import Bug |
10 | from lp.bugs.model.bugtask import BugTask |
11 | from lp.registry.model.product import Product |
12 | @@ -165,7 +166,7 @@ |
13 | def _updateRosettaStatistics(self, ztm): |
14 | self.update( |
15 | 'products_using_rosetta', |
16 | - Product.selectBy(official_rosetta=True).count() |
17 | + Product.selectBy(translations_usage=ServiceUsage.LAUNCHPAD).count() |
18 | ) |
19 | self.update('potemplate_count', POTemplate.select().count()) |
20 | ztm.commit() |
21 | |
22 | === modified file 'lib/lp/answers/model/question.py' |
23 | --- lib/lp/answers/model/question.py 2010-10-03 15:30:06 +0000 |
24 | +++ lib/lp/answers/model/question.py 2010-11-04 00:35:23 +0000 |
25 | @@ -1,4 +1,4 @@ |
26 | -# Copyright 2009 Canonical Ltd. This software is licensed under the |
27 | +# Copyright 2009-2010 Canonical Ltd. This software is licensed under the |
28 | # GNU Affero General Public License version 3 (see the file LICENSE). |
29 | |
30 | # pylint: disable-msg=E0611,W0212 |
31 | @@ -88,6 +88,7 @@ |
32 | from lp.answers.model.answercontact import AnswerContact |
33 | from lp.answers.model.questionmessage import QuestionMessage |
34 | from lp.answers.model.questionsubscription import QuestionSubscription |
35 | +from lp.app.enums import ServiceUsage |
36 | from lp.bugs.interfaces.buglink import IBugLinkTarget |
37 | from lp.bugs.interfaces.bugtask import BugTaskStatus |
38 | from lp.bugs.model.buglinktarget import BugLinkTargetMixin |
39 | @@ -680,8 +681,8 @@ |
40 | LEFT OUTER JOIN Distribution ON ( |
41 | Question.distribution = Distribution.id) |
42 | WHERE |
43 | - (Product.official_answers is True |
44 | - OR Distribution.official_answers is TRUE) |
45 | + (Product.answers_usage = %s |
46 | + OR Distribution.answers_usage = %s) |
47 | AND Question.datecreated > ( |
48 | current_timestamp -interval '60 days') |
49 | LIMIT 5000 |
50 | @@ -689,7 +690,8 @@ |
51 | GROUP BY product, distribution |
52 | ORDER BY question_count DESC |
53 | LIMIT %s |
54 | - """ % sqlvalues(limit)) |
55 | + """ % sqlvalues( |
56 | + ServiceUsage.LAUNCHPAD, ServiceUsage.LAUNCHPAD, limit)) |
57 | |
58 | projects = [] |
59 | product_set = getUtility(IProductSet) |
60 | |
61 | === modified file 'lib/lp/registry/model/product.py' |
62 | --- lib/lp/registry/model/product.py 2010-11-03 22:37:55 +0000 |
63 | +++ lib/lp/registry/model/product.py 2010-11-04 12:54:30 +0000 |
64 | @@ -1570,7 +1570,7 @@ |
65 | Product.active == True, |
66 | Product.id == ProductSeries.productID, |
67 | POTemplate.productseriesID == ProductSeries.id, |
68 | - Product.official_rosetta == True, |
69 | + Product.translations_usage == ServiceUsage.LAUNCHPAD, |
70 | Person.id == Product._ownerID, |
71 | ).config(distinct=True).order_by(Product.title) |
72 | |
73 | @@ -1590,12 +1590,12 @@ |
74 | ProductSeries.Product = Product.id |
75 | JOIN POTemplate ON |
76 | POTemplate.productseries = ProductSeries.id |
77 | - WHERE Product.active AND Product.official_rosetta |
78 | + WHERE Product.active AND Product.translations_usage = %s |
79 | ORDER BY place |
80 | ) AS randomized_products |
81 | LIMIT %s |
82 | ) |
83 | - ''' % quote(maximumproducts), |
84 | + ''' % quote(ServiceUsage.LAUNCHPAD, maximumproducts), |
85 | distinct=True, |
86 | orderBy='Product.title') |
87 | |
88 | |
89 | === modified file 'lib/lp/registry/model/projectgroup.py' |
90 | --- lib/lp/registry/model/projectgroup.py 2010-11-02 20:10:56 +0000 |
91 | +++ lib/lp/registry/model/projectgroup.py 2010-11-04 12:54:30 +0000 |
92 | @@ -175,7 +175,7 @@ |
93 | def getConfigurableProducts(self): |
94 | return [product for product in self.products |
95 | if check_permission('launchpad.Edit', product)] |
96 | - |
97 | + |
98 | @property |
99 | def drivers(self): |
100 | """See `IHasDrivers`.""" |
101 | @@ -185,19 +185,15 @@ |
102 | |
103 | def translatables(self): |
104 | """See `IProjectGroup`.""" |
105 | - # XXX j.c.sackett 2010-08-30 bug=627631: Once data migration has |
106 | - # happened for the usage enums, this sql needs to be updated to |
107 | - # check for the translations_usage, not official_rosetta. At that |
108 | - # time it should also be converted to a Storm query and the issue with |
109 | - # has_translatables resolved. |
110 | - return Product.select(''' |
111 | - Product.project = %s AND |
112 | - Product.official_rosetta = TRUE AND |
113 | - Product.id = ProductSeries.product AND |
114 | - POTemplate.productseries = ProductSeries.id |
115 | - ''' % sqlvalues(self), |
116 | - clauseTables=['ProductSeries', 'POTemplate'], |
117 | - distinct=True) |
118 | + store = Store.of(self) |
119 | + results = store.find( |
120 | + Product, |
121 | + AND( |
122 | + Product.project == self.id, |
123 | + Product.translations_usage == ServiceUsage.LAUNCHPAD, |
124 | + Product == ProductSeries.product, |
125 | + POTemplate.productseries == ProductSeries.id)) |
126 | + return results.config(distinct=True) |
127 | |
128 | def has_translatable(self): |
129 | """See `IProjectGroup`.""" |
130 | @@ -205,7 +201,7 @@ |
131 | # converted to use is_empty but the implementation in storm's |
132 | # sqlobject wrapper is broken. |
133 | # return not self.translatables().is_empty() |
134 | - return self.translatables().count() != 0 |
135 | + return self.translatables().is_empty() |
136 | |
137 | def has_branches(self): |
138 | """ See `IProjectGroup`.""" |
139 | |
140 | === modified file 'lib/lp/translations/model/translationsoverview.py' |
141 | --- lib/lp/translations/model/translationsoverview.py 2010-08-31 23:03:45 +0000 |
142 | +++ lib/lp/translations/model/translationsoverview.py 2010-11-04 01:38:24 +0000 |
143 | @@ -7,6 +7,7 @@ |
144 | from zope.interface import implements |
145 | |
146 | from canonical.database.sqlbase import cursor |
147 | +from lp.app.enums import ServiceUsage |
148 | from lp.registry.model.distribution import Distribution |
149 | from lp.registry.model.product import Product |
150 | from lp.translations.interfaces.translationsoverview import ( |
151 | @@ -45,9 +46,6 @@ |
152 | def getMostTranslatedPillars(self, limit=50): |
153 | """See `ITranslationsOverview`.""" |
154 | |
155 | - # XXX j.c.sackett 2010-08-30 bug=627631 Once data migration has |
156 | - # happened for the usage enums, this sql needs to be updated |
157 | - # to check for the translations_usage, not official_rosetta. |
158 | query = """ |
159 | SELECT LOWER(COALESCE(product_name, distro_name)) AS name, |
160 | product_id, |
161 | @@ -67,14 +65,16 @@ |
162 | distribution=distribution.id |
163 | WHERE category=3 AND |
164 | (product IS NOT NULL OR distribution IS NOT NULL) AND |
165 | - (product.official_rosetta OR |
166 | - distribution.official_rosetta) |
167 | + (product.translations_usage = %s OR |
168 | + distribution.tranlsations_usage = %s) |
169 | GROUP BY product.displayname, product.id, |
170 | distribution.displayname, distribution.id |
171 | HAVING SUM(karmavalue) > 0 |
172 | ORDER BY total_karma DESC |
173 | LIMIT %d) AS something |
174 | - ORDER BY name""" % int(limit) |
175 | + ORDER BY name""" % sqlvalues(ServiceUsage.LAUNCHPAD, |
176 | + ServiceUsage.LAUNCHPAD, |
177 | + int(limit)) |
178 | cur = cursor() |
179 | cur.execute(query) |
180 | |
181 | |
182 | === modified file 'lib/lp/translations/model/translationsperson.py' |
183 | --- lib/lp/translations/model/translationsperson.py 2010-08-31 23:03:45 +0000 |
184 | +++ lib/lp/translations/model/translationsperson.py 2010-11-03 17:56:46 +0000 |
185 | @@ -262,9 +262,6 @@ |
186 | The added joins may make the overall query non-distinct, so be |
187 | sure to enforce distinctness. |
188 | """ |
189 | - # XXX j.c.sackett 2010-08-30 bug=627631 Once data migration has |
190 | - # happened for the usage enums, this query needs to be updated |
191 | - # to check for the translations_usage, not official_rosetta. |
192 | |
193 | POTemplateJoin = Join(POTemplate, And( |
194 | POTemplate.id == POFile.potemplateID, |
195 | @@ -282,7 +279,7 @@ |
196 | # translation focus. |
197 | distrojoin_conditions = And( |
198 | Distribution.id == DistroSeries.distributionID, |
199 | - Distribution.official_rosetta == True, |
200 | + Distribution.translations_usage == ServiceUsage.LAUNCHPAD, |
201 | Distribution.translation_focusID == DistroSeries.id) |
202 | |
203 | DistroJoin = LeftJoin(Distribution, distrojoin_conditions) |
204 | @@ -291,7 +288,7 @@ |
205 | ProductSeries, ProductSeries.id == POTemplate.productseriesID) |
206 | ProductJoin = LeftJoin(Product, And( |
207 | Product.id == ProductSeries.productID, |
208 | - Product.official_rosetta == True)) |
209 | + Product.translations_usage == ServiceUsage.LAUNCHPAD)) |
210 | |
211 | ProjectJoin = LeftJoin( |
212 | ProjectGroup, ProjectGroup.id == Product.projectID) |
213 | |
214 | === modified file 'lib/lp/translations/scripts/translations_to_branch.py' |
215 | --- lib/lp/translations/scripts/translations_to_branch.py 2010-10-02 11:41:43 +0000 |
216 | +++ lib/lp/translations/scripts/translations_to_branch.py 2010-11-04 01:48:10 +0000 |
217 | @@ -306,15 +306,13 @@ |
218 | |
219 | self.store = getUtility(IStoreSelector).get(MAIN_STORE, SLAVE_FLAVOR) |
220 | |
221 | - # XXX j.c.sackett 2010-08-30 bug=627631 Once data migration has |
222 | - # happened for the usage enums, this sql needs to be updated to |
223 | - # check for the translations_usage, not official_rosetta. |
224 | product_join = Join( |
225 | ProductSeries, Product, ProductSeries.product == Product.id) |
226 | productseries = self.store.using(product_join).find( |
227 | - ProductSeries, SQL( |
228 | - "official_rosetta AND translations_branch IS NOT NULL")) |
229 | - |
230 | + ProductSeries, |
231 | + AND( |
232 | + Product.translations_usage == ServiceUsage.LAUNCHPAD, |
233 | + Product.translations_branch is not None)) |
234 | # Anything deterministic will do, and even that is only for |
235 | # testing. |
236 | productseries = productseries.order_by(ProductSeries.id) |
I had to remove the changes from the prerequisite branch, but now the diff seems huge. I've attached a smaller more clear diff.