Merge lp:~cjwatson/launchpad/getpublishedbinaries-sorting into lp:launchpad
- getpublishedbinaries-sorting
- Merge into devel
Status: | Merged |
---|---|
Merged at revision: | 17425 |
Proposed branch: | lp:~cjwatson/launchpad/getpublishedbinaries-sorting |
Merge into: | lp:launchpad |
Diff against target: |
752 lines (+198/-148) 12 files modified
lib/lp/archivepublisher/tests/test_ftparchive.py (+2/-2) lib/lp/archivepublisher/tests/test_publisher.py (+1/-1) lib/lp/registry/doc/distroseries.txt (+2/-2) lib/lp/soyuz/doc/archive.txt (+23/-23) lib/lp/soyuz/interfaces/archive.py (+23/-4) lib/lp/soyuz/model/archive.py (+110/-102) lib/lp/soyuz/scripts/tests/test_initialize_distroseries.py (+3/-3) lib/lp/soyuz/stories/ppa/xx-ppa-packages.txt (+1/-1) lib/lp/soyuz/stories/webservice/xx-binary-package-publishing.txt (+1/-1) lib/lp/soyuz/stories/webservice/xx-source-package-publishing.txt (+1/-1) lib/lp/soyuz/tests/test_archive.py (+28/-6) lib/lp/soyuz/tests/test_packagecopyjob.py (+3/-2) |
To merge this branch: | bzr merge lp:~cjwatson/launchpad/getpublishedbinaries-sorting |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
William Grant | code | Approve | |
Review via email: mp+255822@code.launchpad.net |
Commit message
Improve performance of Archive.
Description of the change
Improve performance of Archive.
It would be nice to insert StormRangeFactory in here too, providing a stable way to slice the returned collection. As explained in the linked bug, though, that is currently difficult, and this is enough to provide a safe API provided that the status filter is omitted (so that entries don't disappear from the collection during iteration).
William Grant (wgrant) : | # |
Preview Diff
1 | === modified file 'lib/lp/archivepublisher/tests/test_ftparchive.py' | |||
2 | --- lib/lp/archivepublisher/tests/test_ftparchive.py 2014-11-24 16:03:20 +0000 | |||
3 | +++ lib/lp/archivepublisher/tests/test_ftparchive.py 2015-04-13 17:14:35 +0000 | |||
4 | @@ -1,4 +1,4 @@ | |||
6 | 1 | # Copyright 2009-2013 Canonical Ltd. This software is licensed under the | 1 | # Copyright 2009-2015 Canonical Ltd. This software is licensed under the |
7 | 2 | # GNU Affero General Public License version 3 (see the file LICENSE). | 2 | # GNU Affero General Public License version 3 (see the file LICENSE). |
8 | 3 | 3 | ||
9 | 4 | """Tests for ftparchive.py""" | 4 | """Tests for ftparchive.py""" |
10 | @@ -308,7 +308,7 @@ | |||
11 | 308 | self._publisher = SamplePublisher(self._archive) | 308 | self._publisher = SamplePublisher(self._archive) |
12 | 309 | fa = self._setUpFTPArchiveHandler() | 309 | fa = self._setUpFTPArchiveHandler() |
13 | 310 | pubs = self._archive.getAllPublishedBinaries( | 310 | pubs = self._archive.getAllPublishedBinaries( |
15 | 311 | name="pmount", status=PackagePublishingStatus.PUBLISHED, | 311 | name=u"pmount", status=PackagePublishingStatus.PUBLISHED, |
16 | 312 | distroarchseries=self._distribution.getSeries("hoary")["hppa"]) | 312 | distroarchseries=self._distribution.getSeries("hoary")["hppa"]) |
17 | 313 | for pub in pubs: | 313 | for pub in pubs: |
18 | 314 | pub.changeOverride(new_phased_update_percentage=30).setPublished() | 314 | pub.changeOverride(new_phased_update_percentage=30).setPublished() |
19 | 315 | 315 | ||
20 | === modified file 'lib/lp/archivepublisher/tests/test_publisher.py' | |||
21 | --- lib/lp/archivepublisher/tests/test_publisher.py 2015-03-18 17:51:16 +0000 | |||
22 | +++ lib/lp/archivepublisher/tests/test_publisher.py 2015-04-13 17:14:35 +0000 | |||
23 | @@ -407,7 +407,7 @@ | |||
24 | 407 | for pu_build in pu_i386.builds: | 407 | for pu_build in pu_i386.builds: |
25 | 408 | pu_build.publish() | 408 | pu_build.publish() |
26 | 409 | 409 | ||
28 | 410 | publications = archive.getAllPublishedBinaries(name="bin-i386") | 410 | publications = archive.getAllPublishedBinaries(name=u"bin-i386") |
29 | 411 | 411 | ||
30 | 412 | self.assertEqual(1, publications.count()) | 412 | self.assertEqual(1, publications.count()) |
31 | 413 | self.assertEqual( | 413 | self.assertEqual( |
32 | 414 | 414 | ||
33 | === modified file 'lib/lp/registry/doc/distroseries.txt' | |||
34 | --- lib/lp/registry/doc/distroseries.txt 2014-11-27 22:13:36 +0000 | |||
35 | +++ lib/lp/registry/doc/distroseries.txt 2015-04-13 17:14:35 +0000 | |||
36 | @@ -342,11 +342,11 @@ | |||
37 | 342 | >>> humpy.getPublishedSources('pmount').count() | 342 | >>> humpy.getPublishedSources('pmount').count() |
38 | 343 | 1 | 343 | 1 |
39 | 344 | >>> hoary.main_archive.getAllPublishedBinaries( | 344 | >>> hoary.main_archive.getAllPublishedBinaries( |
41 | 345 | ... distroarchseries=hoary['i386'], name='pmount', | 345 | ... distroarchseries=hoary['i386'], name=u'pmount', |
42 | 346 | ... status=PackagePublishingStatus.PUBLISHED).count() | 346 | ... status=PackagePublishingStatus.PUBLISHED).count() |
43 | 347 | 1 | 347 | 1 |
44 | 348 | >>> humpy.main_archive.getAllPublishedBinaries( | 348 | >>> humpy.main_archive.getAllPublishedBinaries( |
46 | 349 | ... distroarchseries=humpy['i386'], name='pmount').count() | 349 | ... distroarchseries=humpy['i386'], name=u'pmount').count() |
47 | 350 | 1 | 350 | 1 |
48 | 351 | 351 | ||
49 | 352 | Check if the attributes of an DRSPR instance for the just initialized | 352 | Check if the attributes of an DRSPR instance for the just initialized |
50 | 353 | 353 | ||
51 | === modified file 'lib/lp/soyuz/doc/archive.txt' | |||
52 | --- lib/lp/soyuz/doc/archive.txt 2014-07-15 02:12:04 +0000 | |||
53 | +++ lib/lp/soyuz/doc/archive.txt 2015-04-13 17:14:35 +0000 | |||
54 | @@ -295,46 +295,46 @@ | |||
55 | 295 | 295 | ||
56 | 296 | 'name' filter supporting partial string matching and 'not-found': | 296 | 'name' filter supporting partial string matching and 'not-found': |
57 | 297 | 297 | ||
59 | 298 | >>> cprov_archive.getPublishedOnDiskBinaries(name='pmou').count() | 298 | >>> cprov_archive.getPublishedOnDiskBinaries(name=u'pmou').count() |
60 | 299 | 1 | 299 | 1 |
62 | 300 | >>> cprov_archive.getAllPublishedBinaries(name='pmou').count() | 300 | >>> cprov_archive.getAllPublishedBinaries(name=u'pmou').count() |
63 | 301 | 2 | 301 | 2 |
65 | 302 | >>> cprov_archive.getPublishedOnDiskBinaries(name='foo').count() | 302 | >>> cprov_archive.getPublishedOnDiskBinaries(name=u'foo').count() |
66 | 303 | 0 | 303 | 0 |
68 | 304 | >>> cprov_archive.getAllPublishedBinaries(name='foo').count() | 304 | >>> cprov_archive.getAllPublishedBinaries(name=u'foo').count() |
69 | 305 | 0 | 305 | 0 |
70 | 306 | 306 | ||
71 | 307 | Combining 'name' filter and 'exact_match' flag: | 307 | Combining 'name' filter and 'exact_match' flag: |
72 | 308 | 308 | ||
73 | 309 | >>> cprov_archive.getAllPublishedBinaries( | 309 | >>> cprov_archive.getAllPublishedBinaries( |
75 | 310 | ... name='pmou', exact_match=True).count() | 310 | ... name=u'pmou', exact_match=True).count() |
76 | 311 | 0 | 311 | 0 |
77 | 312 | >>> cprov_archive.getAllPublishedBinaries( | 312 | >>> cprov_archive.getAllPublishedBinaries( |
79 | 313 | ... name='pmount', exact_match=True).count() | 313 | ... name=u'pmount', exact_match=True).count() |
80 | 314 | 2 | 314 | 2 |
81 | 315 | >>> cprov_archive.getPublishedOnDiskBinaries( | 315 | >>> cprov_archive.getPublishedOnDiskBinaries( |
83 | 316 | ... name='pmou', exact_match=True).count() | 316 | ... name=u'pmou', exact_match=True).count() |
84 | 317 | 0 | 317 | 0 |
85 | 318 | >>> cprov_archive.getPublishedOnDiskBinaries( | 318 | >>> cprov_archive.getPublishedOnDiskBinaries( |
87 | 319 | ... name='pmount', exact_match=True).count() | 319 | ... name=u'pmount', exact_match=True).count() |
88 | 320 | 1 | 320 | 1 |
89 | 321 | 321 | ||
90 | 322 | It's possible to associate 'name' and 'version' filters: | 322 | It's possible to associate 'name' and 'version' filters: |
91 | 323 | 323 | ||
92 | 324 | >>> cprov_archive.getPublishedOnDiskBinaries( | 324 | >>> cprov_archive.getPublishedOnDiskBinaries( |
94 | 325 | ... name='moz', version='1.0').count() | 325 | ... name=u'moz', version='1.0').count() |
95 | 326 | 2 | 326 | 2 |
96 | 327 | 327 | ||
97 | 328 | >>> cprov_archive.getAllPublishedBinaries( | 328 | >>> cprov_archive.getAllPublishedBinaries( |
99 | 329 | ... name='moz', version='1.0').count() | 329 | ... name=u'moz', version='1.0').count() |
100 | 330 | 2 | 330 | 2 |
101 | 331 | 331 | ||
102 | 332 | >>> cprov_archive.getPublishedOnDiskBinaries( | 332 | >>> cprov_archive.getPublishedOnDiskBinaries( |
104 | 333 | ... name='moz', version='666').count() | 333 | ... name=u'moz', version='666').count() |
105 | 334 | 0 | 334 | 0 |
106 | 335 | 335 | ||
107 | 336 | >>> cprov_archive.getAllPublishedBinaries( | 336 | >>> cprov_archive.getAllPublishedBinaries( |
109 | 337 | ... name='moz', version='666').count() | 337 | ... name=u'moz', version='666').count() |
110 | 338 | 0 | 338 | 0 |
111 | 339 | 339 | ||
112 | 340 | Both methods do not support passing the 'version' filter if the 'name' | 340 | Both methods do not support passing the 'version' filter if the 'name' |
113 | @@ -429,44 +429,44 @@ | |||
114 | 429 | Associating 'name' and 'status' filters: | 429 | Associating 'name' and 'status' filters: |
115 | 430 | 430 | ||
116 | 431 | >>> status_lookup = cprov_archive.getPublishedOnDiskBinaries( | 431 | >>> status_lookup = cprov_archive.getPublishedOnDiskBinaries( |
118 | 432 | ... name='pmount', status=active_status) | 432 | ... name=u'pmount', status=active_status) |
119 | 433 | >>> status_lookup.count() | 433 | >>> status_lookup.count() |
120 | 434 | 1 | 434 | 1 |
121 | 435 | 435 | ||
122 | 436 | >>> status_lookup = cprov_archive.getAllPublishedBinaries( | 436 | >>> status_lookup = cprov_archive.getAllPublishedBinaries( |
124 | 437 | ... name='pmount', status=active_status) | 437 | ... name=u'pmount', status=active_status) |
125 | 438 | >>> status_lookup.count() | 438 | >>> status_lookup.count() |
126 | 439 | 2 | 439 | 2 |
127 | 440 | 440 | ||
128 | 441 | >>> status_lookup = cprov_archive.getPublishedOnDiskBinaries( | 441 | >>> status_lookup = cprov_archive.getPublishedOnDiskBinaries( |
130 | 442 | ... name='foo', status=active_status) | 442 | ... name=u'foo', status=active_status) |
131 | 443 | >>> status_lookup.count() | 443 | >>> status_lookup.count() |
132 | 444 | 0 | 444 | 0 |
133 | 445 | 445 | ||
134 | 446 | >>> status_lookup = cprov_archive.getAllPublishedBinaries( | 446 | >>> status_lookup = cprov_archive.getAllPublishedBinaries( |
136 | 447 | ... name='foo', status=active_status) | 447 | ... name=u'foo', status=active_status) |
137 | 448 | >>> status_lookup.count() | 448 | >>> status_lookup.count() |
138 | 449 | 0 | 449 | 0 |
139 | 450 | 450 | ||
140 | 451 | Associating 'name', 'version' and 'status' filters: | 451 | Associating 'name', 'version' and 'status' filters: |
141 | 452 | 452 | ||
142 | 453 | >>> status_lookup = cprov_archive.getPublishedOnDiskBinaries( | 453 | >>> status_lookup = cprov_archive.getPublishedOnDiskBinaries( |
144 | 454 | ... name='pmount', version='0.1-1', status=active_status) | 454 | ... name=u'pmount', version='0.1-1', status=active_status) |
145 | 455 | >>> status_lookup.count() | 455 | >>> status_lookup.count() |
146 | 456 | 1 | 456 | 1 |
147 | 457 | 457 | ||
148 | 458 | >>> status_lookup = cprov_archive.getAllPublishedBinaries( | 458 | >>> status_lookup = cprov_archive.getAllPublishedBinaries( |
150 | 459 | ... name='pmount', version='0.1-1', status=active_status) | 459 | ... name=u'pmount', version='0.1-1', status=active_status) |
151 | 460 | >>> status_lookup.count() | 460 | >>> status_lookup.count() |
152 | 461 | 2 | 461 | 2 |
153 | 462 | 462 | ||
154 | 463 | >>> status_lookup = cprov_archive.getPublishedOnDiskBinaries( | 463 | >>> status_lookup = cprov_archive.getPublishedOnDiskBinaries( |
156 | 464 | ... name='pmount', version='666', status=active_status) | 464 | ... name=u'pmount', version='666', status=active_status) |
157 | 465 | >>> status_lookup.count() | 465 | >>> status_lookup.count() |
158 | 466 | 0 | 466 | 0 |
159 | 467 | 467 | ||
160 | 468 | >>> status_lookup = cprov_archive.getAllPublishedBinaries( | 468 | >>> status_lookup = cprov_archive.getAllPublishedBinaries( |
162 | 469 | ... name='pmount', version='666', status=active_status) | 469 | ... name=u'pmount', version='666', status=active_status) |
163 | 470 | >>> status_lookup.count() | 470 | >>> status_lookup.count() |
164 | 471 | 0 | 471 | 0 |
165 | 472 | 472 | ||
166 | @@ -474,13 +474,13 @@ | |||
167 | 474 | and 'exact_match' flag: | 474 | and 'exact_match' flag: |
168 | 475 | 475 | ||
169 | 476 | >>> status_lookup = cprov_archive.getAllPublishedBinaries( | 476 | >>> status_lookup = cprov_archive.getAllPublishedBinaries( |
171 | 477 | ... name='pmount', version='0.1-1', distroarchseries=warty_i386, | 477 | ... name=u'pmount', version='0.1-1', distroarchseries=warty_i386, |
172 | 478 | ... status=active_status, exact_match=True) | 478 | ... status=active_status, exact_match=True) |
173 | 479 | >>> status_lookup.count() | 479 | >>> status_lookup.count() |
174 | 480 | 1 | 480 | 1 |
175 | 481 | 481 | ||
176 | 482 | >>> status_lookup = cprov_archive.getAllPublishedBinaries( | 482 | >>> status_lookup = cprov_archive.getAllPublishedBinaries( |
178 | 483 | ... name='pmount', version='0.1-1', | 483 | ... name=u'pmount', version='0.1-1', |
179 | 484 | ... distroarchseries=[warty_i386, warty_hppa], | 484 | ... distroarchseries=[warty_i386, warty_hppa], |
180 | 485 | ... status=active_status, exact_match=True) | 485 | ... status=active_status, exact_match=True) |
181 | 486 | >>> status_lookup.count() | 486 | >>> status_lookup.count() |
182 | @@ -592,7 +592,7 @@ | |||
183 | 592 | >>> cprov_archive.number_of_binaries | 592 | >>> cprov_archive.number_of_binaries |
184 | 593 | 3 | 593 | 3 |
185 | 594 | >>> cprov_archive.getAllPublishedBinaries( | 594 | >>> cprov_archive.getAllPublishedBinaries( |
187 | 595 | ... name='mozilla-firefox')[0].supersede() | 595 | ... name=u'mozilla-firefox')[0].supersede() |
188 | 596 | 596 | ||
189 | 597 | >>> cprov_archive.number_of_binaries | 597 | >>> cprov_archive.number_of_binaries |
190 | 598 | 2 | 598 | 2 |
191 | 599 | 599 | ||
192 | === modified file 'lib/lp/soyuz/interfaces/archive.py' | |||
193 | --- lib/lp/soyuz/interfaces/archive.py 2014-08-14 10:08:28 +0000 | |||
194 | +++ lib/lp/soyuz/interfaces/archive.py 2015-04-13 17:14:35 +0000 | |||
195 | @@ -1,4 +1,4 @@ | |||
197 | 1 | # Copyright 2009-2013 Canonical Ltd. This software is licensed under the | 1 | # Copyright 2009-2015 Canonical Ltd. This software is licensed under the |
198 | 2 | # GNU Affero General Public License version 3 (see the file LICENSE). | 2 | # GNU Affero General Public License version 3 (see the file LICENSE). |
199 | 3 | 3 | ||
200 | 4 | """Archive interfaces.""" | 4 | """Archive interfaces.""" |
201 | @@ -449,6 +449,12 @@ | |||
202 | 449 | "than or equal to this date."), | 449 | "than or equal to this date."), |
203 | 450 | required=False), | 450 | required=False), |
204 | 451 | component_name=TextLine(title=_("Component name"), required=False), | 451 | component_name=TextLine(title=_("Component name"), required=False), |
205 | 452 | order_by_date=Bool( | ||
206 | 453 | title=_("Order by creation date"), | ||
207 | 454 | description=_("Return newest results first. This is recommended " | ||
208 | 455 | "for applications that need to catch up with " | ||
209 | 456 | "publications since their last run."), | ||
210 | 457 | required=False), | ||
211 | 452 | ) | 458 | ) |
212 | 453 | # Really returns ISourcePackagePublishingHistory, see below for | 459 | # Really returns ISourcePackagePublishingHistory, see below for |
213 | 454 | # patch to avoid circular import. | 460 | # patch to avoid circular import. |
214 | @@ -457,7 +463,7 @@ | |||
215 | 457 | def api_getPublishedSources(name=None, version=None, status=None, | 463 | def api_getPublishedSources(name=None, version=None, status=None, |
216 | 458 | distroseries=None, pocket=None, | 464 | distroseries=None, pocket=None, |
217 | 459 | exact_match=False, created_since_date=None, | 465 | exact_match=False, created_since_date=None, |
219 | 460 | component_name=None): | 466 | component_name=None, order_by_date=False): |
220 | 461 | """All `ISourcePackagePublishingHistory` target to this archive.""" | 467 | """All `ISourcePackagePublishingHistory` target to this archive.""" |
221 | 462 | # It loads additional related objects only needed in the API call | 468 | # It loads additional related objects only needed in the API call |
222 | 463 | # context (i.e. security checks and entries marshalling). | 469 | # context (i.e. security checks and entries marshalling). |
223 | @@ -465,7 +471,8 @@ | |||
224 | 465 | def getPublishedSources(name=None, version=None, status=None, | 471 | def getPublishedSources(name=None, version=None, status=None, |
225 | 466 | distroseries=None, pocket=None, | 472 | distroseries=None, pocket=None, |
226 | 467 | exact_match=False, created_since_date=None, | 473 | exact_match=False, created_since_date=None, |
228 | 468 | eager_load=False, component_name=None): | 474 | eager_load=False, component_name=None, |
229 | 475 | order_by_date=False): | ||
230 | 469 | """All `ISourcePackagePublishingHistory` target to this archive. | 476 | """All `ISourcePackagePublishingHistory` target to this archive. |
231 | 470 | 477 | ||
232 | 471 | :param name: source name filter (exact match or SQL LIKE controlled | 478 | :param name: source name filter (exact match or SQL LIKE controlled |
233 | @@ -482,6 +489,9 @@ | |||
234 | 482 | is greater than or equal to this date. | 489 | is greater than or equal to this date. |
235 | 483 | :param component_name: component filter. Only return source packages | 490 | :param component_name: component filter. Only return source packages |
236 | 484 | that are in this component. | 491 | that are in this component. |
237 | 492 | :param order_by_date: Order publications by descending creation date | ||
238 | 493 | and then by descending ID. This is suitable for applications | ||
239 | 494 | that need to catch up with publications since their last run. | ||
240 | 485 | 495 | ||
241 | 486 | :return: SelectResults containing `ISourcePackagePublishingHistory`, | 496 | :return: SelectResults containing `ISourcePackagePublishingHistory`, |
242 | 487 | ordered by name. If there are multiple results for the same | 497 | ordered by name. If there are multiple results for the same |
243 | @@ -1110,6 +1120,12 @@ | |||
244 | 1110 | description=_("Return ordered results by default, but specifying " | 1120 | description=_("Return ordered results by default, but specifying " |
245 | 1111 | "False will return results more quickly."), | 1121 | "False will return results more quickly."), |
246 | 1112 | required=False, readonly=True), | 1122 | required=False, readonly=True), |
247 | 1123 | order_by_date=Bool( | ||
248 | 1124 | title=_("Order by creation date"), | ||
249 | 1125 | description=_("Return newest results first. This is recommended " | ||
250 | 1126 | "for applications that need to catch up with " | ||
251 | 1127 | "publications since their last run."), | ||
252 | 1128 | required=False), | ||
253 | 1113 | ) | 1129 | ) |
254 | 1114 | # Really returns ISourcePackagePublishingHistory, see below for | 1130 | # Really returns ISourcePackagePublishingHistory, see below for |
255 | 1115 | # patch to avoid circular import. | 1131 | # patch to avoid circular import. |
256 | @@ -1119,7 +1135,7 @@ | |||
257 | 1119 | def getAllPublishedBinaries(name=None, version=None, status=None, | 1135 | def getAllPublishedBinaries(name=None, version=None, status=None, |
258 | 1120 | distroarchseries=None, pocket=None, | 1136 | distroarchseries=None, pocket=None, |
259 | 1121 | exact_match=False, created_since_date=None, | 1137 | exact_match=False, created_since_date=None, |
261 | 1122 | ordered=True): | 1138 | ordered=True, order_by_date=False): |
262 | 1123 | """All `IBinaryPackagePublishingHistory` target to this archive. | 1139 | """All `IBinaryPackagePublishingHistory` target to this archive. |
263 | 1124 | 1140 | ||
264 | 1125 | :param name: binary name filter (exact match or SQL LIKE controlled | 1141 | :param name: binary name filter (exact match or SQL LIKE controlled |
265 | @@ -1137,6 +1153,9 @@ | |||
266 | 1137 | False then the results will be unordered. This will make the | 1153 | False then the results will be unordered. This will make the |
267 | 1138 | operation much quicker to return results if you don't care about | 1154 | operation much quicker to return results if you don't care about |
268 | 1139 | ordering. | 1155 | ordering. |
269 | 1156 | :param order_by_date: Order publications by descending creation date | ||
270 | 1157 | and then by descending ID. This is suitable for applications | ||
271 | 1158 | that need to catch up with publications since their last run. | ||
272 | 1140 | 1159 | ||
273 | 1141 | :return: A collection containing `BinaryPackagePublishingHistory`. | 1160 | :return: A collection containing `BinaryPackagePublishingHistory`. |
274 | 1142 | """ | 1161 | """ |
275 | 1143 | 1162 | ||
276 | === modified file 'lib/lp/soyuz/model/archive.py' | |||
277 | --- lib/lp/soyuz/model/archive.py 2015-03-12 13:59:27 +0000 | |||
278 | +++ lib/lp/soyuz/model/archive.py 2015-04-13 17:14:35 +0000 | |||
279 | @@ -97,7 +97,6 @@ | |||
280 | 97 | ) | 97 | ) |
281 | 98 | from lp.services.database.sqlbase import ( | 98 | from lp.services.database.sqlbase import ( |
282 | 99 | cursor, | 99 | cursor, |
283 | 100 | quote_like, | ||
284 | 101 | SQLBase, | 100 | SQLBase, |
285 | 102 | sqlvalues, | 101 | sqlvalues, |
286 | 103 | ) | 102 | ) |
287 | @@ -521,13 +520,16 @@ | |||
288 | 521 | def api_getPublishedSources(self, name=None, version=None, status=None, | 520 | def api_getPublishedSources(self, name=None, version=None, status=None, |
289 | 522 | distroseries=None, pocket=None, | 521 | distroseries=None, pocket=None, |
290 | 523 | exact_match=False, created_since_date=None, | 522 | exact_match=False, created_since_date=None, |
292 | 524 | component_name=None): | 523 | order_by_date=False, component_name=None): |
293 | 525 | """See `IArchive`.""" | 524 | """See `IArchive`.""" |
294 | 526 | # 'eager_load' and 'include_removed' arguments are always True | 525 | # 'eager_load' and 'include_removed' arguments are always True |
295 | 527 | # for API calls. | 526 | # for API calls. |
296 | 528 | published_sources = self.getPublishedSources( | 527 | published_sources = self.getPublishedSources( |
299 | 529 | name, version, status, distroseries, pocket, exact_match, | 528 | name=name, version=version, status=status, |
300 | 530 | created_since_date, True, component_name, True) | 529 | distroseries=distroseries, pocket=pocket, exact_match=exact_match, |
301 | 530 | created_since_date=created_since_date, eager_load=True, | ||
302 | 531 | component_name=component_name, order_by_date=order_by_date, | ||
303 | 532 | include_removed=True) | ||
304 | 531 | 533 | ||
305 | 532 | def load_api_extra_objects(rows): | 534 | def load_api_extra_objects(rows): |
306 | 533 | """Load extra related-objects needed by API calls.""" | 535 | """Load extra related-objects needed by API calls.""" |
307 | @@ -565,20 +567,23 @@ | |||
308 | 565 | distroseries=None, pocket=None, | 567 | distroseries=None, pocket=None, |
309 | 566 | exact_match=False, created_since_date=None, | 568 | exact_match=False, created_since_date=None, |
310 | 567 | eager_load=False, component_name=None, | 569 | eager_load=False, component_name=None, |
312 | 568 | include_removed=True): | 570 | order_by_date=False, include_removed=True): |
313 | 569 | """See `IArchive`.""" | 571 | """See `IArchive`.""" |
326 | 570 | # clauses contains literal sql expressions for things that don't work | 572 | clauses = [SourcePackagePublishingHistory.archiveID == self.id] |
327 | 571 | # easily in storm : this method was migrated from sqlobject but some | 573 | |
328 | 572 | # callers are problematic. (Migrate them and test to see). | 574 | if order_by_date: |
329 | 573 | clauses = [ | 575 | order_by = [ |
330 | 574 | SourcePackagePublishingHistory.archiveID == self.id, | 576 | Desc(SourcePackagePublishingHistory.datecreated), |
331 | 575 | SourcePackagePublishingHistory.sourcepackagereleaseID == | 577 | Desc(SourcePackagePublishingHistory.id)] |
332 | 576 | SourcePackageRelease.id, | 578 | else: |
333 | 577 | SourcePackagePublishingHistory.sourcepackagenameID == | 579 | order_by = [ |
334 | 578 | SourcePackageName.id] | 580 | SourcePackageName.name, |
335 | 579 | orderBy = [ | 581 | Desc(SourcePackagePublishingHistory.id)] |
336 | 580 | SourcePackageName.name, | 582 | |
337 | 581 | Desc(SourcePackagePublishingHistory.id)] | 583 | if not order_by_date or name is not None: |
338 | 584 | clauses.append( | ||
339 | 585 | SourcePackagePublishingHistory.sourcepackagenameID == | ||
340 | 586 | SourcePackageName.id) | ||
341 | 582 | 587 | ||
342 | 583 | if name is not None: | 588 | if name is not None: |
343 | 584 | if type(name) in (str, unicode): | 589 | if type(name) in (str, unicode): |
344 | @@ -590,14 +595,19 @@ | |||
345 | 590 | elif len(name) != 0: | 595 | elif len(name) != 0: |
346 | 591 | clauses.append(SourcePackageName.name.is_in(name)) | 596 | clauses.append(SourcePackageName.name.is_in(name)) |
347 | 592 | 597 | ||
348 | 598 | if not order_by_date or version is not None: | ||
349 | 599 | clauses.append( | ||
350 | 600 | SourcePackagePublishingHistory.sourcepackagereleaseID == | ||
351 | 601 | SourcePackageRelease.id) | ||
352 | 602 | |||
353 | 593 | if version is not None: | 603 | if version is not None: |
354 | 594 | if name is None: | 604 | if name is None: |
355 | 595 | raise VersionRequiresName( | 605 | raise VersionRequiresName( |
356 | 596 | "The 'version' parameter can be used only together with" | 606 | "The 'version' parameter can be used only together with" |
357 | 597 | " the 'name' parameter.") | 607 | " the 'name' parameter.") |
358 | 598 | clauses.append(SourcePackageRelease.version == version) | 608 | clauses.append(SourcePackageRelease.version == version) |
361 | 599 | else: | 609 | elif not order_by_date: |
362 | 600 | orderBy.insert(1, Desc(SourcePackageRelease.version)) | 610 | order_by.insert(1, Desc(SourcePackageRelease.version)) |
363 | 601 | 611 | ||
364 | 602 | if component_name is not None: | 612 | if component_name is not None: |
365 | 603 | clauses.extend( | 613 | clauses.extend( |
366 | @@ -635,7 +645,7 @@ | |||
367 | 635 | 645 | ||
368 | 636 | store = Store.of(self) | 646 | store = Store.of(self) |
369 | 637 | resultset = store.find( | 647 | resultset = store.find( |
371 | 638 | SourcePackagePublishingHistory, *clauses).order_by(*orderBy) | 648 | SourcePackagePublishingHistory, *clauses).order_by(*order_by) |
372 | 639 | if not eager_load: | 649 | if not eager_load: |
373 | 640 | return resultset | 650 | return resultset |
374 | 641 | 651 | ||
375 | @@ -747,38 +757,46 @@ | |||
376 | 747 | def _getBinaryPublishingBaseClauses( | 757 | def _getBinaryPublishingBaseClauses( |
377 | 748 | self, name=None, version=None, status=None, distroarchseries=None, | 758 | self, name=None, version=None, status=None, distroarchseries=None, |
378 | 749 | pocket=None, exact_match=False, created_since_date=None, | 759 | pocket=None, exact_match=False, created_since_date=None, |
381 | 750 | ordered=True, include_removed=True): | 760 | ordered=True, order_by_date=False, include_removed=True, |
382 | 751 | """Base clauses and clauseTables for binary publishing queries. | 761 | need_bpr=False): |
383 | 762 | """Base clauses for binary publishing queries. | ||
384 | 752 | 763 | ||
387 | 753 | Returns a list of 'clauses' (to be joined in the callsite) and | 764 | Returns a list of 'clauses' (to be joined in the callsite). |
386 | 754 | a list of clauseTables required according to the given arguments. | ||
388 | 755 | """ | 765 | """ |
400 | 756 | clauses = [""" | 766 | clauses = [BinaryPackagePublishingHistory.archiveID == self.id] |
401 | 757 | BinaryPackagePublishingHistory.archive = %s AND | 767 | |
402 | 758 | BinaryPackagePublishingHistory.binarypackagerelease = | 768 | if order_by_date: |
403 | 759 | BinaryPackageRelease.id AND | 769 | ordered = False |
404 | 760 | BinaryPackagePublishingHistory.binarypackagename = | 770 | |
405 | 761 | BinaryPackageName.id | 771 | if order_by_date: |
406 | 762 | """ % sqlvalues(self)] | 772 | order_by = [ |
407 | 763 | clauseTables = ['BinaryPackageRelease', 'BinaryPackageName'] | 773 | Desc(BinaryPackagePublishingHistory.datecreated), |
408 | 764 | if ordered: | 774 | Desc(BinaryPackagePublishingHistory.id)] |
409 | 765 | orderBy = ['BinaryPackageName.name', | 775 | elif ordered: |
410 | 766 | '-BinaryPackagePublishingHistory.id'] | 776 | order_by = [ |
411 | 777 | BinaryPackageName.name, | ||
412 | 778 | Desc(BinaryPackagePublishingHistory.id)] | ||
413 | 767 | else: | 779 | else: |
414 | 768 | # Strictly speaking, this is ordering, but it's an indexed | 780 | # Strictly speaking, this is ordering, but it's an indexed |
415 | 769 | # ordering so it will be quick. It's needed so that we can | 781 | # ordering so it will be quick. It's needed so that we can |
416 | 770 | # batch results on the webservice. | 782 | # batch results on the webservice. |
418 | 771 | orderBy = ['-BinaryPackagePublishingHistory.id'] | 783 | order_by = [Desc(BinaryPackagePublishingHistory.id)] |
419 | 784 | |||
420 | 785 | if ordered or name is not None: | ||
421 | 786 | clauses.append( | ||
422 | 787 | BinaryPackagePublishingHistory.binarypackagenameID == | ||
423 | 788 | BinaryPackageName.id) | ||
424 | 772 | 789 | ||
425 | 773 | if name is not None: | 790 | if name is not None: |
426 | 774 | if exact_match: | 791 | if exact_match: |
430 | 775 | clauses.append(""" | 792 | clauses.append(BinaryPackageName.name == name) |
428 | 776 | BinaryPackageName.name=%s | ||
429 | 777 | """ % sqlvalues(name)) | ||
431 | 778 | else: | 793 | else: |
435 | 779 | clauses.append(""" | 794 | clauses.append(BinaryPackageName.name.contains_string(name)) |
436 | 780 | BinaryPackageName.name LIKE '%%' || %s || '%%' | 795 | |
437 | 781 | """ % quote_like(name)) | 796 | if need_bpr or ordered or version is not None: |
438 | 797 | clauses.append( | ||
439 | 798 | BinaryPackagePublishingHistory.binarypackagereleaseID == | ||
440 | 799 | BinaryPackageRelease.id) | ||
441 | 782 | 800 | ||
442 | 783 | if version is not None: | 801 | if version is not None: |
443 | 784 | if name is None: | 802 | if name is None: |
444 | @@ -786,115 +804,105 @@ | |||
445 | 786 | "The 'version' parameter can be used only together with" | 804 | "The 'version' parameter can be used only together with" |
446 | 787 | " the 'name' parameter.") | 805 | " the 'name' parameter.") |
447 | 788 | 806 | ||
451 | 789 | clauses.append(""" | 807 | clauses.append(BinaryPackageRelease.version == version) |
449 | 790 | BinaryPackageRelease.version = %s | ||
450 | 791 | """ % sqlvalues(version)) | ||
452 | 792 | elif ordered: | 808 | elif ordered: |
454 | 793 | orderBy.insert(1, Desc(BinaryPackageRelease.version)) | 809 | order_by.insert(1, Desc(BinaryPackageRelease.version)) |
455 | 794 | 810 | ||
456 | 795 | if status is not None: | 811 | if status is not None: |
457 | 796 | try: | 812 | try: |
458 | 797 | status = tuple(status) | 813 | status = tuple(status) |
459 | 798 | except TypeError: | 814 | except TypeError: |
460 | 799 | status = (status, ) | 815 | status = (status, ) |
464 | 800 | clauses.append(""" | 816 | clauses.append(BinaryPackagePublishingHistory.status.is_in(status)) |
462 | 801 | BinaryPackagePublishingHistory.status IN %s | ||
463 | 802 | """ % sqlvalues(status)) | ||
465 | 803 | 817 | ||
466 | 804 | if distroarchseries is not None: | 818 | if distroarchseries is not None: |
467 | 805 | try: | 819 | try: |
468 | 806 | distroarchseries = tuple(distroarchseries) | 820 | distroarchseries = tuple(distroarchseries) |
469 | 807 | except TypeError: | 821 | except TypeError: |
470 | 808 | distroarchseries = (distroarchseries, ) | 822 | distroarchseries = (distroarchseries, ) |
477 | 809 | # XXX cprov 20071016: there is no sqlrepr for DistroArchSeries | 823 | clauses.append( |
478 | 810 | # uhmm, how so ? | 824 | BinaryPackagePublishingHistory.distroarchseriesID.is_in( |
479 | 811 | das_ids = "(%s)" % ", ".join(str(d.id) for d in distroarchseries) | 825 | [d.id for d in distroarchseries])) |
474 | 812 | clauses.append(""" | ||
475 | 813 | BinaryPackagePublishingHistory.distroarchseries IN %s | ||
476 | 814 | """ % das_ids) | ||
480 | 815 | 826 | ||
481 | 816 | if pocket is not None: | 827 | if pocket is not None: |
485 | 817 | clauses.append(""" | 828 | clauses.append(BinaryPackagePublishingHistory.pocket == pocket) |
483 | 818 | BinaryPackagePublishingHistory.pocket = %s | ||
484 | 819 | """ % sqlvalues(pocket)) | ||
486 | 820 | 829 | ||
487 | 821 | if created_since_date is not None: | 830 | if created_since_date is not None: |
488 | 822 | clauses.append( | 831 | clauses.append( |
491 | 823 | "BinaryPackagePublishingHistory.datecreated >= %s" | 832 | BinaryPackagePublishingHistory.datecreated >= |
492 | 824 | % sqlvalues(created_since_date)) | 833 | created_since_date) |
493 | 825 | 834 | ||
494 | 826 | if not include_removed: | 835 | if not include_removed: |
497 | 827 | clauses.append( | 836 | clauses.append(BinaryPackagePublishingHistory.dateremoved == None) |
496 | 828 | "BinaryPackagePublishingHistory.dateremoved IS NULL") | ||
498 | 829 | 837 | ||
500 | 830 | return clauses, clauseTables, orderBy | 838 | return clauses, order_by |
501 | 831 | 839 | ||
502 | 832 | def getAllPublishedBinaries(self, name=None, version=None, status=None, | 840 | def getAllPublishedBinaries(self, name=None, version=None, status=None, |
503 | 833 | distroarchseries=None, pocket=None, | 841 | distroarchseries=None, pocket=None, |
504 | 834 | exact_match=False, created_since_date=None, | 842 | exact_match=False, created_since_date=None, |
506 | 835 | ordered=True, include_removed=True): | 843 | ordered=True, order_by_date=False, |
507 | 844 | include_removed=True): | ||
508 | 836 | """See `IArchive`.""" | 845 | """See `IArchive`.""" |
510 | 837 | clauses, clauseTables, orderBy = self._getBinaryPublishingBaseClauses( | 846 | clauses, order_by = self._getBinaryPublishingBaseClauses( |
511 | 838 | name=name, version=version, status=status, pocket=pocket, | 847 | name=name, version=version, status=status, pocket=pocket, |
512 | 839 | distroarchseries=distroarchseries, exact_match=exact_match, | 848 | distroarchseries=distroarchseries, exact_match=exact_match, |
513 | 840 | created_since_date=created_since_date, ordered=ordered, | 849 | created_since_date=created_since_date, ordered=ordered, |
521 | 841 | include_removed=include_removed) | 850 | order_by_date=order_by_date, include_removed=include_removed) |
522 | 842 | 851 | ||
523 | 843 | all_binaries = BinaryPackagePublishingHistory.select( | 852 | return Store.of(self).find( |
524 | 844 | ' AND '.join(clauses), clauseTables=clauseTables, | 853 | BinaryPackagePublishingHistory, *clauses).order_by(*order_by) |
518 | 845 | orderBy=orderBy) | ||
519 | 846 | |||
520 | 847 | return all_binaries | ||
525 | 848 | 854 | ||
526 | 849 | def getPublishedOnDiskBinaries(self, name=None, version=None, status=None, | 855 | def getPublishedOnDiskBinaries(self, name=None, version=None, status=None, |
527 | 850 | distroarchseries=None, pocket=None, | 856 | distroarchseries=None, pocket=None, |
530 | 851 | exact_match=False, | 857 | exact_match=False): |
529 | 852 | created_since_date=None): | ||
531 | 853 | """See `IArchive`.""" | 858 | """See `IArchive`.""" |
533 | 854 | clauses, clauseTables, orderBy = self._getBinaryPublishingBaseClauses( | 859 | # Circular imports. |
534 | 860 | from lp.registry.model.distroseries import DistroSeries | ||
535 | 861 | from lp.soyuz.model.distroarchseries import DistroArchSeries | ||
536 | 862 | |||
537 | 863 | clauses, order_by = self._getBinaryPublishingBaseClauses( | ||
538 | 855 | name=name, version=version, status=status, pocket=pocket, | 864 | name=name, version=version, status=status, pocket=pocket, |
539 | 856 | distroarchseries=distroarchseries, exact_match=exact_match, | 865 | distroarchseries=distroarchseries, exact_match=exact_match, |
548 | 857 | created_since_date=created_since_date) | 866 | need_bpr=True) |
549 | 858 | 867 | ||
550 | 859 | clauses.append(""" | 868 | clauses.extend([ |
551 | 860 | BinaryPackagePublishingHistory.distroarchseries = | 869 | BinaryPackagePublishingHistory.distroarchseriesID == |
552 | 861 | DistroArchSeries.id AND | 870 | DistroArchSeries.id, |
553 | 862 | DistroArchSeries.distroseries = DistroSeries.id | 871 | DistroArchSeries.distroseriesID == DistroSeries.id, |
554 | 863 | """) | 872 | ]) |
555 | 864 | clauseTables.extend(['DistroSeries', 'DistroArchSeries']) | 873 | |
556 | 874 | store = Store.of(self) | ||
557 | 865 | 875 | ||
558 | 866 | # Retrieve only the binaries published for the 'nominated architecture | 876 | # Retrieve only the binaries published for the 'nominated architecture |
559 | 867 | # independent' (usually i386) in the distroseries in question. | 877 | # independent' (usually i386) in the distroseries in question. |
560 | 868 | # It includes all architecture-independent binaries only once and the | 878 | # It includes all architecture-independent binaries only once and the |
561 | 869 | # architecture-specific built for 'nominatedarchindep'. | 879 | # architecture-specific built for 'nominatedarchindep'. |
570 | 870 | nominated_arch_independent_clause = [""" | 880 | nominated_arch_independent_clauses = clauses + [ |
571 | 871 | DistroSeries.nominatedarchindep = | 881 | DistroSeries.nominatedarchindepID == |
572 | 872 | BinaryPackagePublishingHistory.distroarchseries | 882 | BinaryPackagePublishingHistory.distroarchseriesID, |
573 | 873 | """] | 883 | ] |
574 | 874 | nominated_arch_independent_query = ' AND '.join( | 884 | nominated_arch_independents = store.find( |
575 | 875 | clauses + nominated_arch_independent_clause) | 885 | BinaryPackagePublishingHistory, |
576 | 876 | nominated_arch_independents = BinaryPackagePublishingHistory.select( | 886 | *nominated_arch_independent_clauses) |
569 | 877 | nominated_arch_independent_query, clauseTables=clauseTables) | ||
577 | 878 | 887 | ||
578 | 879 | # Retrieve all architecture-specific binary publications except | 888 | # Retrieve all architecture-specific binary publications except |
579 | 880 | # 'nominatedarchindep' (already included in the previous query). | 889 | # 'nominatedarchindep' (already included in the previous query). |
590 | 881 | no_nominated_arch_independent_clause = [""" | 890 | no_nominated_arch_independent_clauses = clauses + [ |
591 | 882 | DistroSeries.nominatedarchindep != | 891 | DistroSeries.nominatedarchindepID != |
592 | 883 | BinaryPackagePublishingHistory.distroarchseries AND | 892 | BinaryPackagePublishingHistory.distroarchseriesID, |
593 | 884 | BinaryPackageRelease.architecturespecific = true | 893 | BinaryPackageRelease.architecturespecific == True, |
594 | 885 | """] | 894 | ] |
595 | 886 | no_nominated_arch_independent_query = ' AND '.join( | 895 | no_nominated_arch_independents = store.find( |
596 | 887 | clauses + no_nominated_arch_independent_clause) | 896 | BinaryPackagePublishingHistory, |
597 | 888 | no_nominated_arch_independents = ( | 897 | *no_nominated_arch_independent_clauses) |
588 | 889 | BinaryPackagePublishingHistory.select( | ||
589 | 890 | no_nominated_arch_independent_query, clauseTables=clauseTables)) | ||
598 | 891 | 898 | ||
599 | 892 | # XXX cprov 20071016: It's not possible to use the same ordering | 899 | # XXX cprov 20071016: It's not possible to use the same ordering |
600 | 893 | # schema returned by self._getBinaryPublishingBaseClauses. | 900 | # schema returned by self._getBinaryPublishingBaseClauses. |
601 | 894 | # It results in: | 901 | # It results in: |
602 | 895 | # ERROR: missing FROM-clause entry for table "binarypackagename" | 902 | # ERROR: missing FROM-clause entry for table "binarypackagename" |
603 | 896 | unique_binary_publications = nominated_arch_independents.union( | 903 | unique_binary_publications = nominated_arch_independents.union( |
605 | 897 | no_nominated_arch_independents).orderBy("id") | 904 | no_nominated_arch_independents).order_by( |
606 | 905 | BinaryPackagePublishingHistory.id) | ||
607 | 898 | 906 | ||
608 | 899 | return unique_binary_publications | 907 | return unique_binary_publications |
609 | 900 | 908 | ||
610 | 901 | 909 | ||
611 | === modified file 'lib/lp/soyuz/scripts/tests/test_initialize_distroseries.py' | |||
612 | --- lib/lp/soyuz/scripts/tests/test_initialize_distroseries.py 2014-11-06 01:42:35 +0000 | |||
613 | +++ lib/lp/soyuz/scripts/tests/test_initialize_distroseries.py 2015-04-13 17:14:35 +0000 | |||
614 | @@ -1,4 +1,4 @@ | |||
616 | 1 | # Copyright 2010-2014 Canonical Ltd. This software is licensed under the | 1 | # Copyright 2010-2015 Canonical Ltd. This software is licensed under the |
617 | 2 | # GNU Affero General Public License version 3 (see the file LICENSE). | 2 | # GNU Affero General Public License version 3 (see the file LICENSE). |
618 | 3 | 3 | ||
619 | 4 | """Test the initialize_distroseries script machinery.""" | 4 | """Test the initialize_distroseries script machinery.""" |
620 | @@ -581,9 +581,9 @@ | |||
621 | 581 | self.assertEqual( | 581 | self.assertEqual( |
622 | 582 | parent_udev_pubs.count(), child_udev_pubs.count()) | 582 | parent_udev_pubs.count(), child_udev_pubs.count()) |
623 | 583 | parent_arch_udev_pubs = parent.main_archive.getAllPublishedBinaries( | 583 | parent_arch_udev_pubs = parent.main_archive.getAllPublishedBinaries( |
625 | 584 | distroarchseries=parent[parent_das.architecturetag], name='udev') | 584 | distroarchseries=parent[parent_das.architecturetag], name=u'udev') |
626 | 585 | child_arch_udev_pubs = child.main_archive.getAllPublishedBinaries( | 585 | child_arch_udev_pubs = child.main_archive.getAllPublishedBinaries( |
628 | 586 | distroarchseries=child[parent_das.architecturetag], name='udev') | 586 | distroarchseries=child[parent_das.architecturetag], name=u'udev') |
629 | 587 | self.assertEqual( | 587 | self.assertEqual( |
630 | 588 | parent_arch_udev_pubs.count(), child_arch_udev_pubs.count()) | 588 | parent_arch_udev_pubs.count(), child_arch_udev_pubs.count()) |
631 | 589 | # And the binary package, and linked source package look fine too. | 589 | # And the binary package, and linked source package look fine too. |
632 | 590 | 590 | ||
633 | === modified file 'lib/lp/soyuz/stories/ppa/xx-ppa-packages.txt' | |||
634 | --- lib/lp/soyuz/stories/ppa/xx-ppa-packages.txt 2014-07-24 09:37:03 +0000 | |||
635 | +++ lib/lp/soyuz/stories/ppa/xx-ppa-packages.txt 2015-04-13 17:14:35 +0000 | |||
636 | @@ -137,7 +137,7 @@ | |||
637 | 137 | >>> cprov = getUtility(IPersonSet).getByName('cprov') | 137 | >>> cprov = getUtility(IPersonSet).getByName('cprov') |
638 | 138 | >>> cprov_ppa = cprov.archive | 138 | >>> cprov_ppa = cprov.archive |
639 | 139 | >>> pmount_i386_pub = cprov_ppa.getAllPublishedBinaries( | 139 | >>> pmount_i386_pub = cprov_ppa.getAllPublishedBinaries( |
641 | 140 | ... name='pmount', version='0.1-1')[1] | 140 | ... name=u'pmount', version='0.1-1')[1] |
642 | 141 | >>> print pmount_i386_pub.displayname | 141 | >>> print pmount_i386_pub.displayname |
643 | 142 | pmount 0.1-1 in warty i386 | 142 | pmount 0.1-1 in warty i386 |
644 | 143 | >>> from lp.soyuz.enums import PackagePublishingStatus | 143 | >>> from lp.soyuz.enums import PackagePublishingStatus |
645 | 144 | 144 | ||
646 | === modified file 'lib/lp/soyuz/stories/webservice/xx-binary-package-publishing.txt' | |||
647 | --- lib/lp/soyuz/stories/webservice/xx-binary-package-publishing.txt 2015-04-08 13:19:19 +0000 | |||
648 | +++ lib/lp/soyuz/stories/webservice/xx-binary-package-publishing.txt 2015-04-13 17:14:35 +0000 | |||
649 | @@ -159,7 +159,7 @@ | |||
650 | 159 | >>> australia = getUtility(ICountrySet)['AU'] | 159 | >>> australia = getUtility(ICountrySet)['AU'] |
651 | 160 | 160 | ||
652 | 161 | >>> firefox_db = cprov_db.archive.getAllPublishedBinaries( | 161 | >>> firefox_db = cprov_db.archive.getAllPublishedBinaries( |
654 | 162 | ... name='mozilla-firefox')[0] | 162 | ... name=u'mozilla-firefox')[0] |
655 | 163 | >>> firefox_db.archive.updatePackageDownloadCount( | 163 | >>> firefox_db.archive.updatePackageDownloadCount( |
656 | 164 | ... firefox_db.binarypackagerelease, date(2010, 2, 21), australia, 10) | 164 | ... firefox_db.binarypackagerelease, date(2010, 2, 21), australia, 10) |
657 | 165 | >>> firefox_db.archive.updatePackageDownloadCount( | 165 | >>> firefox_db.archive.updatePackageDownloadCount( |
658 | 166 | 166 | ||
659 | === modified file 'lib/lp/soyuz/stories/webservice/xx-source-package-publishing.txt' | |||
660 | --- lib/lp/soyuz/stories/webservice/xx-source-package-publishing.txt 2014-07-24 09:37:03 +0000 | |||
661 | +++ lib/lp/soyuz/stories/webservice/xx-source-package-publishing.txt 2015-04-13 17:14:35 +0000 | |||
662 | @@ -216,7 +216,7 @@ | |||
663 | 216 | 216 | ||
664 | 217 | >>> login("admin@canonical.com") | 217 | >>> login("admin@canonical.com") |
665 | 218 | >>> for bin in cprov_ppa.getAllPublishedBinaries( | 218 | >>> for bin in cprov_ppa.getAllPublishedBinaries( |
667 | 219 | ... name="testwebservice-bin"): | 219 | ... name=u"testwebservice-bin"): |
668 | 220 | ... if bin.status != PackagePublishingStatus.DELETED: | 220 | ... if bin.status != PackagePublishingStatus.DELETED: |
669 | 221 | ... print "%s is not deleted when it should be" % bin.displayname | 221 | ... print "%s is not deleted when it should be" % bin.displayname |
670 | 222 | ... else: | 222 | ... else: |
671 | 223 | 223 | ||
672 | === modified file 'lib/lp/soyuz/tests/test_archive.py' | |||
673 | --- lib/lp/soyuz/tests/test_archive.py 2015-03-12 13:59:27 +0000 | |||
674 | +++ lib/lp/soyuz/tests/test_archive.py 2015-04-13 17:14:35 +0000 | |||
675 | @@ -2187,14 +2187,24 @@ | |||
676 | 2187 | component_name='universe') | 2187 | component_name='universe') |
677 | 2188 | self.assertEqual('universe', filtered.component.name) | 2188 | self.assertEqual('universe', filtered.component.name) |
678 | 2189 | 2189 | ||
681 | 2190 | 2190 | def test_order_by_date(self): | |
682 | 2191 | class GetPublishedSourcesWebServiceTests(TestCaseWithFactory): | 2191 | archive = self.factory.makeArchive() |
683 | 2192 | dates = [self.factory.getUniqueDate() for _ in range(5)] | ||
684 | 2193 | # Make sure the ID ordering and date ordering don't match so that we | ||
685 | 2194 | # can spot a date-ordered result. | ||
686 | 2195 | pubs = [ | ||
687 | 2196 | self.factory.makeSourcePackagePublishingHistory( | ||
688 | 2197 | archive=archive, date_uploaded=dates[(i + 1) % 5]) | ||
689 | 2198 | for i in range(5)] | ||
690 | 2199 | self.assertEqual( | ||
691 | 2200 | [pubs[i] for i in (3, 2, 1, 0, 4)], | ||
692 | 2201 | list(archive.getPublishedSources(order_by_date=True))) | ||
693 | 2202 | |||
694 | 2203 | |||
695 | 2204 | class TestGetPublishedSourcesWebService(TestCaseWithFactory): | ||
696 | 2192 | 2205 | ||
697 | 2193 | layer = LaunchpadFunctionalLayer | 2206 | layer = LaunchpadFunctionalLayer |
698 | 2194 | 2207 | ||
699 | 2195 | def setUp(self): | ||
700 | 2196 | super(GetPublishedSourcesWebServiceTests, self).setUp() | ||
701 | 2197 | |||
702 | 2198 | def createTestingPPA(self): | 2208 | def createTestingPPA(self): |
703 | 2199 | """Creates and populates a PPA for API performance tests. | 2209 | """Creates and populates a PPA for API performance tests. |
704 | 2200 | 2210 | ||
705 | @@ -2208,7 +2218,6 @@ | |||
706 | 2208 | # XXX cprov 2014-04-22: currently the target archive owner cannot | 2218 | # XXX cprov 2014-04-22: currently the target archive owner cannot |
707 | 2209 | # 'addSource' to a `PackageUpload` ('launchpad.Edit'). It seems | 2219 | # 'addSource' to a `PackageUpload` ('launchpad.Edit'). It seems |
708 | 2210 | # too restrive to me. | 2220 | # too restrive to me. |
709 | 2211 | from zope.security.proxy import removeSecurityProxy | ||
710 | 2212 | with person_logged_in(ppa.owner): | 2221 | with person_logged_in(ppa.owner): |
711 | 2213 | for i in range(5): | 2222 | for i in range(5): |
712 | 2214 | upload = self.factory.makePackageUpload( | 2223 | upload = self.factory.makePackageUpload( |
713 | @@ -2814,6 +2823,19 @@ | |||
714 | 2814 | publications, | 2823 | publications, |
715 | 2815 | [first_publication, middle_publication, later_publication]) | 2824 | [first_publication, middle_publication, later_publication]) |
716 | 2816 | 2825 | ||
717 | 2826 | def test_order_by_date(self): | ||
718 | 2827 | archive = self.factory.makeArchive() | ||
719 | 2828 | dates = [self.factory.getUniqueDate() for _ in range(5)] | ||
720 | 2829 | # Make sure the ID ordering and date ordering don't match so that we | ||
721 | 2830 | # can spot a date-ordered result. | ||
722 | 2831 | pubs = [ | ||
723 | 2832 | self.factory.makeBinaryPackagePublishingHistory( | ||
724 | 2833 | archive=archive, datecreated=dates[(i + 1) % 5]) | ||
725 | 2834 | for i in range(5)] | ||
726 | 2835 | self.assertEqual( | ||
727 | 2836 | [pubs[i] for i in (3, 2, 1, 0, 4)], | ||
728 | 2837 | list(archive.getAllPublishedBinaries(order_by_date=True))) | ||
729 | 2838 | |||
730 | 2817 | 2839 | ||
731 | 2818 | class TestRemovingPermissions(TestCaseWithFactory): | 2840 | class TestRemovingPermissions(TestCaseWithFactory): |
732 | 2819 | 2841 | ||
733 | 2820 | 2842 | ||
734 | === modified file 'lib/lp/soyuz/tests/test_packagecopyjob.py' | |||
735 | --- lib/lp/soyuz/tests/test_packagecopyjob.py 2014-08-14 09:54:33 +0000 | |||
736 | +++ lib/lp/soyuz/tests/test_packagecopyjob.py 2015-04-13 17:14:35 +0000 | |||
737 | @@ -1,4 +1,4 @@ | |||
739 | 1 | # Copyright 2010-2014 Canonical Ltd. This software is licensed under the | 1 | # Copyright 2010-2015 Canonical Ltd. This software is licensed under the |
740 | 2 | # GNU Affero General Public License version 3 (see the file LICENSE). | 2 | # GNU Affero General Public License version 3 (see the file LICENSE). |
741 | 3 | 3 | ||
742 | 4 | """Tests for sync package jobs.""" | 4 | """Tests for sync package jobs.""" |
743 | @@ -1392,7 +1392,8 @@ | |||
744 | 1392 | copied_sources = target_archive.getPublishedSources( | 1392 | copied_sources = target_archive.getPublishedSources( |
745 | 1393 | name=u"copyme", version="2.8-1") | 1393 | name=u"copyme", version="2.8-1") |
746 | 1394 | self.assertNotEqual(0, copied_sources.count()) | 1394 | self.assertNotEqual(0, copied_sources.count()) |
748 | 1395 | copied_binaries = target_archive.getAllPublishedBinaries(name="copyme") | 1395 | copied_binaries = target_archive.getAllPublishedBinaries( |
749 | 1396 | name=u"copyme") | ||
750 | 1396 | self.assertNotEqual(0, copied_binaries.count()) | 1397 | self.assertNotEqual(0, copied_binaries.count()) |
751 | 1397 | 1398 | ||
752 | 1398 | # Check that files were unembargoed. | 1399 | # Check that files were unembargoed. |