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
=== modified file 'lib/lp/code/model/sourcepackagerecipe.py'
--- lib/lp/code/model/sourcepackagerecipe.py 2018-03-02 01:11:48 +0000
+++ lib/lp/code/model/sourcepackagerecipe.py 2018-05-09 11:03:05 +0000
@@ -395,11 +395,13 @@
395 """Return the median duration of builds of this recipe."""395 """Return the median duration of builds of this recipe."""
396 store = IStore(self)396 store = IStore(self)
397 result = store.find(397 result = store.find(
398 SourcePackageRecipeBuild,398 (SourcePackageRecipeBuild.date_started,
399 SourcePackageRecipeBuild.date_finished),
399 SourcePackageRecipeBuild.recipe == self.id,400 SourcePackageRecipeBuild.recipe == self.id,
401 SourcePackageRecipeBuild.status == BuildStatus.FULLYBUILT,
400 SourcePackageRecipeBuild.date_finished != None)402 SourcePackageRecipeBuild.date_finished != None)
401 durations = [403 result.order_by(Desc(SourcePackageRecipeBuild.date_finished))
402 build.date_finished - build.date_started for build in result]404 durations = [row[1] - row[0] for row in result[:9]]
403 if len(durations) == 0:405 if len(durations) == 0:
404 return None406 return None
405 durations.sort(reverse=True)407 durations.sort(reverse=True)