Merge lp:~michael.nelson/launchpad/437037-queue-timeout into lp:launchpad

Proposed by Michael Nelson
Status: Merged
Merged at revision: not available
Proposed branch: lp:~michael.nelson/launchpad/437037-queue-timeout
Merge into: lp:launchpad
Diff against target: 39 lines
1 file modified
lib/lp/soyuz/model/sourcepackagerelease.py (+10/-12)
To merge this branch: bzr merge lp:~michael.nelson/launchpad/437037-queue-timeout
Reviewer Review Type Date Requested Status
Eleanor Berger (community) Approve
Review via email: mp+12513@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Michael Nelson (michael.nelson) wrote :

= Summary =

This branch avoids instantiating SourcePackageRelease objects just to
find their IDs for the IN-clause of the next query, by combining the two
queries into one.

== Proposed fix ==

== Pre-implementation notes ==

== Implementation details ==

== Tests ==

bin/test -vvt doc/build.txt

== Demo and Q/A ==
No demo.

QA - We'll need to get Scott to provide feedback. We could qa on df with
the right setup if needed.

= 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/soyuz/model/sourcepackagerelease.py

--
Michael

Revision history for this message
Eleanor Berger (intellectronica) :
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/model/sourcepackagerelease.py'
2--- lib/lp/soyuz/model/sourcepackagerelease.py 2009-09-23 12:02:35 +0000
3+++ lib/lp/soyuz/model/sourcepackagerelease.py 2009-09-28 08:45:25 +0000
4@@ -341,25 +341,23 @@
5 if archive.purpose != ArchivePurpose.PRIMARY:
6 archives.append(distroarchseries.main_archive.id)
7
8- # Look for all sourcepackagerelease instances that match the name.
9- matching_sprs = SourcePackageRelease.select("""
10+ # Look for all sourcepackagerelease instances that match the name
11+ # and get the (successfully built) build records for this
12+ # package.
13+ completed_builds = Build.select("""
14+ Build.sourcepackagerelease = SourcePackageRelease.id AND
15+ SourcePackageRelease.sourcepackagename = SourcePackageName.id AND
16 SourcePackageName.name = %s AND
17- SourcePackageRelease.sourcepackagename = SourcePackageName.id
18- """ % sqlvalues(self.name),
19- clauseTables=['SourcePackageName', 'SourcePackageRelease'])
20-
21- # Get the (successfully built) build records for this package.
22- completed_builds = Build.select("""
23- sourcepackagerelease IN %s AND
24 distroarchseries = %s AND
25 archive IN %s AND
26 buildstate = %s
27- """ % sqlvalues([spr.id for spr in matching_sprs],
28+ """ % sqlvalues(self.name,
29 distroarchseries, archives,
30 BuildStatus.FULLYBUILT),
31- orderBy=['-datebuilt', '-id'])
32+ orderBy=['-datebuilt', '-id'],
33+ clauseTables=['SourcePackageName', 'SourcePackageRelease'])
34
35- if completed_builds:
36+ if completed_builds.count() > 0:
37 # Historic build data exists, use the most recent value.
38 most_recent_build = completed_builds[0]
39 estimated_build_duration = most_recent_build.buildduration