Merge lp:~cjwatson/launchpad/spr-faster-time-estimation into lp:launchpad

Proposed by Colin Watson
Status: Merged
Merged at revision: 18640
Proposed branch: lp:~cjwatson/launchpad/spr-faster-time-estimation
Merge into: lp:launchpad
Diff against target: 20 lines (+5/-3)
1 file modified
lib/lp/code/model/sourcepackagerecipe.py (+5/-3)
To merge this branch: bzr merge lp:~cjwatson/launchpad/spr-faster-time-estimation
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+345289@code.launchpad.net

Commit message

Only consider the most recent nine successful builds when estimating recipe build durations.

Description of the change

Pulling every single completed build of the recipe back into Python is liable to time out.

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) wrote :

Quite.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/code/model/sourcepackagerecipe.py'
2--- lib/lp/code/model/sourcepackagerecipe.py 2018-03-02 01:11:48 +0000
3+++ lib/lp/code/model/sourcepackagerecipe.py 2018-05-09 11:03:05 +0000
4@@ -395,11 +395,13 @@
5 """Return the median duration of builds of this recipe."""
6 store = IStore(self)
7 result = store.find(
8- SourcePackageRecipeBuild,
9+ (SourcePackageRecipeBuild.date_started,
10+ SourcePackageRecipeBuild.date_finished),
11 SourcePackageRecipeBuild.recipe == self.id,
12+ SourcePackageRecipeBuild.status == BuildStatus.FULLYBUILT,
13 SourcePackageRecipeBuild.date_finished != None)
14- durations = [
15- build.date_finished - build.date_started for build in result]
16+ result.order_by(Desc(SourcePackageRecipeBuild.date_finished))
17+ durations = [row[1] - row[0] for row in result[:9]]
18 if len(durations) == 0:
19 return None
20 durations.sort(reverse=True)