Merge lp:~lifeless/launchpad/bug-711104 into lp:launchpad

Proposed by Robert Collins on 2011-03-14
Status: Merged
Approved by: Tim Penhey on 2011-03-14
Approved revision: no longer in the source branch.
Merged at revision: 12589
Proposed branch: lp:~lifeless/launchpad/bug-711104
Merge into: lp:launchpad
Diff against target: 58 lines (+13/-3)
2 files modified
lib/lp/soyuz/interfaces/binarypackagebuild.py (+2/-0)
lib/lp/soyuz/model/binarypackagebuild.py (+11/-3)
To merge this branch: bzr merge lp:~lifeless/launchpad/bug-711104
Reviewer Review Type Date Requested Status
Tim Penhey (community) 2011-03-14 Approve on 2011-03-14
Review via email: mp+53188@code.launchpad.net

Commit message

eager load PackageBuild and BuildFarmJob for +uploaded-packages

Description of the change

Eager load PackageBuild and BuildFarmJob for +uploaded-packages

To post a comment you must log in.
Robert Collins (lifeless) wrote :

Note that the changed function only has one call site.

Tim Penhey (thumper) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/soyuz/interfaces/binarypackagebuild.py'
2--- lib/lp/soyuz/interfaces/binarypackagebuild.py 2011-01-24 20:57:37 +0000
3+++ lib/lp/soyuz/interfaces/binarypackagebuild.py 2011-03-14 02:29:58 +0000
4@@ -353,6 +353,8 @@
5 buildstate=None):
6 """Return all builds related with the given list of source releases.
7
8+ Eager loads the PackageBuild and BuildFarmJob records for the builds.
9+
10 :param sourcepackagerelease_ids: list of `ISourcePackageRelease`s;
11 :param buildstate: option build state filter.
12
13
14=== modified file 'lib/lp/soyuz/model/binarypackagebuild.py'
15--- lib/lp/soyuz/model/binarypackagebuild.py 2011-01-26 21:22:49 +0000
16+++ lib/lp/soyuz/model/binarypackagebuild.py 2011-03-14 02:29:58 +0000
17@@ -19,6 +19,7 @@
18 Desc,
19 Join,
20 LeftJoin,
21+ SQL,
22 )
23 from storm.locals import (
24 Int,
25@@ -57,6 +58,7 @@
26 from canonical.launchpad.interfaces.lpstorm import (
27 IMasterObject,
28 ISlaveStore,
29+ IStore,
30 )
31 from canonical.launchpad.mail import (
32 format_address,
33@@ -1101,6 +1103,8 @@
34 if (sourcepackagerelease_ids is None or
35 len(sourcepackagerelease_ids) == 0):
36 return []
37+ # Circular.
38+ from lp.soyuz.model.archive import Archive
39
40 query = """
41 source_package_release IN %s AND
42@@ -1113,9 +1117,13 @@
43 if buildstate is not None:
44 query += "AND buildfarmjob.status = %s" % sqlvalues(buildstate)
45
46- return BinaryPackageBuild.select(
47- query, orderBy=["-buildfarmjob.date_created", "id"],
48- clauseTables=["Archive", "PackageBuild", "BuildFarmJob"])
49+ resultset = IStore(BinaryPackageBuild).using(
50+ BinaryPackageBuild, PackageBuild, BuildFarmJob, Archive).find(
51+ (BinaryPackageBuild, PackageBuild, BuildFarmJob),
52+ SQL(query))
53+ resultset.order_by(
54+ Desc(BuildFarmJob.date_created), BinaryPackageBuild.id)
55+ return DecoratedResultSet(resultset, operator.itemgetter(0))
56
57 def getStatusSummaryForBuilds(self, builds):
58 """See `IBinaryPackageBuildSet`."""