branch: main
commit 78bdc15acefbbf3ff5f04d5d7c6edd0a391d689b
Author: Ludovic Courtès <l...@gnu.org>
AuthorDate: Fri May 24 14:22:01 2024 +0200

    database: Add ‘timestamp’ field to <build-summary>.
    
    * src/cuirass/database.scm (<build-summary>)[timestamp]: New field.
    (db-get-evaluations-build-summary): Select ‘evaltime’ and ‘timestamp’
    and fill out ‘timestamp’ field.
---
 src/cuirass/database.scm | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/cuirass/database.scm b/src/cuirass/database.scm
index 9263338..2f29d45 100644
--- a/src/cuirass/database.scm
+++ b/src/cuirass/database.scm
@@ -112,6 +112,7 @@
             build-summary?
             build-summary-evaluation-id
             build-summary-status
+            build-summary-timestamp
             build-summary-checkouts
             build-summary-succeeded
             build-summary-failed
@@ -1743,6 +1744,7 @@ ORDER BY id DESC LIMIT :limit;")
   this-build-summary
   (evaluation-id build-summary-evaluation-id)
   (status        build-summary-status)
+  (timestamp     build-summary-timestamp)
   (checkouts     build-summary-checkouts
                  (thunked)
                  (default (db-get-checkouts
@@ -1756,13 +1758,14 @@ ORDER BY id DESC LIMIT :limit;")
   (with-db-connection db
     (let loop ((rows (exec-query/bind db "
 SELECT E.id, E.status,
+ (CASE WHEN E.status = 0 THEN E.evaltime ELSE E.timestamp END),
 SUM(CASE WHEN B.status = 0 THEN 1 ELSE 0 END) as succeeded,
 SUM(CASE WHEN B.status > 0 THEN 1 ELSE 0 END) as failed,
 SUM(CASE WHEN B.status < 0 THEN 1 ELSE 0 END) as scheduled,
 SUM(CASE WHEN (B.status > 0 AND B.weather = " (build-weather new-failure) ")\
     THEN 1 ELSE 0 END) as newfailures
 FROM
-(SELECT id, status FROM Evaluations
+(SELECT id, status, evaltime, timestamp FROM Evaluations
  WHERE specification = " spec "
 AND (id > " border-low " OR " border-low "::text IS NULL)
 AND (id < " border-high " OR " border-high "::text IS NULL)
@@ -1770,17 +1773,18 @@ ORDER BY CASE WHEN " border-low "::text IS NULL THEN id 
ELSE -id END DESC
 LIMIT " limit ") E
 LEFT JOIN Builds as B
 ON B.evaluation = E.id
-GROUP BY E.id, E.status
+GROUP BY E.id, E.status, E.evaltime, E.timestamp
 ORDER BY E.id DESC;"))
                (summaries '()))
       (match rows
         (()
          (reverse summaries))
-        (((id status succeeded failed scheduled newly-failed) . rest)
+        (((id status timestamp succeeded failed scheduled newly-failed) . rest)
          (loop rest
                (cons (build-summary
                       (evaluation-id (string->number id))
                       (status (string->number status))
+                      (timestamp (string->number timestamp))
                       (checkouts (db-get-checkouts id))
                       (succeeded (or (string->number succeeded) 0))
                       (failed (or (string->number failed) 0))

Reply via email to