[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: database: Fix db-get-build-percentages.
From: |
Mathieu Othacehe |
Subject: |
branch master updated: database: Fix db-get-build-percentages. |
Date: |
Tue, 20 Apr 2021 03:21:57 -0400 |
This is an automated email from the git hooks/post-receive script.
mothacehe pushed a commit to branch master
in repository guix-cuirass.
The following commit(s) were added to refs/heads/master by this push:
new a946fe2 database: Fix db-get-build-percentages.
a946fe2 is described below
commit a946fe2e541b190dfc8e58e7f4259778210e424c
Author: Mathieu Othacehe <othacehe@gnu.org>
AuthorDate: Tue Apr 20 09:21:35 2021 +0200
database: Fix db-get-build-percentages.
* src/cuirass/database.scm (db-get-build-percentages): Fix it.
---
src/cuirass/database.scm | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/src/cuirass/database.scm b/src/cuirass/database.scm
index 3cab518..b773c4e 100644
--- a/src/cuirass/database.scm
+++ b/src/cuirass/database.scm
@@ -671,14 +671,15 @@ WHERE specification = " specification
(with-db-worker-thread db
(let loop ((rows
(exec-query/bind db "
-SELECT COALESCE((SELECT
-LEAST(duration::float/last_duration * 100, 100)::int AS percentage
+SELECT CASE WHEN last_duration = 0 THEN
+0 ELSE LEAST(duration::float/last_duration * 100, 100)::int END AS percentage
FROM (SELECT DISTINCT ON (b1.id) b1.id AS id,
-GREATEST((b2.stoptime - b2.starttime), 1) AS last_duration,
+COALESCE((b2.stoptime - b2.starttime), 0) AS last_duration,
(extract(epoch from now())::int - b1.starttime) AS duration FROM builds AS b1
-LEFT JOIN builds AS b2 ON b1.job_name = b2.job_name WHERE b1.id IN
+LEFT JOIN builds AS b2 ON b1.job_name = b2.job_name
+AND b2.status >= 0 WHERE b1.id IN
(SELECT id FROM builds WHERE id = ANY(" build-ids "))
-AND b2.status >= 0 ORDER BY b1.id, b2.id DESC) d), 0);"))
+ORDER BY b1.id, b2.id DESC) d;"))
(percentages '()))
(match rows
(() (reverse percentages))