← Back to team overview

launchpad-reviewers team mailing list archive

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

 

Colin Watson has proposed merging lp:~cjwatson/launchpad/spr-faster-time-estimation into lp:launchpad.

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

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #1770121 in Launchpad itself: "manual build request timeouts for recipes with a gazillion builds"
  https://bugs.launchpad.net/launchpad/+bug/1770121

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/spr-faster-time-estimation/+merge/345289

Pulling every single completed build of the recipe back into Python is liable to time out.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/spr-faster-time-estimation into lp:launchpad.
=== 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 @@
         """Return the median duration of builds of this recipe."""
         store = IStore(self)
         result = store.find(
-            SourcePackageRecipeBuild,
+            (SourcePackageRecipeBuild.date_started,
+             SourcePackageRecipeBuild.date_finished),
             SourcePackageRecipeBuild.recipe == self.id,
+            SourcePackageRecipeBuild.status == BuildStatus.FULLYBUILT,
             SourcePackageRecipeBuild.date_finished != None)
-        durations = [
-            build.date_finished - build.date_started for build in result]
+        result.order_by(Desc(SourcePackageRecipeBuild.date_finished))
+        durations = [row[1] - row[0] for row in result[:9]]
         if len(durations) == 0:
             return None
         durations.sort(reverse=True)


Follow ups