#2421 hub: getAverageBuildDuration sliding window
Merged 2 years ago by tkopecek. Opened 2 years ago by tkopecek.
tkopecek/koji issue2420  into  master

file modified
+1 -1
@@ -1363,7 +1363,7 @@ 

          weight is scaled from a minimum of 1.5 to a maximum of 6, based on

          the average duration of a build of this package.

          """

-         avg = self.session.getAverageBuildDuration(name)

+         avg = self.session.getAverageBuildDuration(name, age=6)

          if not avg:

              return

          if avg < 0:

file modified
+10 -4
@@ -11377,11 +11377,15 @@ 

          tag_id = get_tag_id(tag, strict=True)

          return maven_tag_archives(tag_id, event_id=event, inherit=inherit)

  

-     def getAverageBuildDuration(self, package):

+     def getAverageBuildDuration(self, package, age=None):

          """Get the average duration of a build of the given package.

-         Returns a floating-point value indicating the

-         average number of seconds the package took to build.  If the package

-         has never been built, return None."""

+ 

+         :param int|str package: Package name or id

+         :param int age: length of history in months

+ 

+         :return float|None: average number of seconds - If package wasn't built

+                             during past age months (or never), None is returned

+         """

          packageID = get_package_id(package)

          if not packageID:

              return None
@@ -11392,6 +11396,8 @@ 

                       WHERE build.pkg_id = %(packageID)i

                         AND build.state = %(st_complete)i

                         AND build.task_id IS NOT NULL"""

+         if age is not None:

+             query += " AND build.completion_time >  NOW() - '%s months'::interval" % int(age)

  

          return _singleValue(query, locals())

  

Metadata Update from @tkopecek:
- Pull-request tagged with: testing-ready

2 years ago

Not sure if anyone else is using this call. I think it might make much sense to add an option to enable/disable this behavior

Metadata Update from @jcupova:
- Pull-request tagged with: testing-done

2 years ago

1 new commit added

  • make age optional
2 years ago

rebased onto b9369b1

2 years ago

Commit df12622 fixes this pull-request

Pull-Request has been merged by tkopecek

2 years ago