From 80318fc0cf9c0595d1c3e677447f3f144deb5690 Mon Sep 17 00:00:00 2001 From: Tomas Kopecek Date: Tue, 14 Jun 2022 13:13:35 +0200 Subject: [PATCH] Correct getAverageDuration values for most GC builds Fixes: https://pagure.io/koji/issue/1128 --- hub/kojihub.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hub/kojihub.py b/hub/kojihub.py index c69ad120..52d365ec 100644 --- a/hub/kojihub.py +++ b/hub/kojihub.py @@ -12449,12 +12449,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)