From 47d3f89ae39aa644c51add8a14624dbfa9167c80 Mon Sep 17 00:00:00 2001 From: Tomas Kopecek Date: Jun 27 2022 15:53:18 +0000 Subject: Correct getAverageDuration values for most GC builds Fixes: https://pagure.io/koji/issue/1128 --- diff --git a/hub/kojihub.py b/hub/kojihub.py index 9642b5e..1b7b8e0 100644 --- a/hub/kojihub.py +++ b/hub/kojihub.py @@ -12479,12 +12479,17 @@ class RootExports(object): if not packageID: return None st_complete = koji.BUILD_STATES['COMPLETE'] + # we need to filter out builds without tasks (imports) as they'll reduce + # time average. CG imported builds often contain *_koji_task_id instead. query = """SELECT date_part('epoch', avg(build.completion_time - events.time)) FROM build JOIN events ON build.create_event = events.id WHERE build.pkg_id = %(packageID)i AND build.state = %(st_complete)i - AND build.task_id IS NOT NULL""" + AND ( + build.task_id IS NOT NULL OR + build.extra LIKE '%koji_task_id%' + )""" if age is not None: query += " AND build.completion_time > NOW() - '%s months'::interval" % int(age)