guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[no subject]


From: Mathieu Othacehe
Date: Thu, 11 Mar 2021 13:32:01 -0500 (EST)

branch: master
commit e3c95014e37437a415fb7edaf4276c21ebc92786
Author: Mathieu Othacehe <othacehe@gnu.org>
AuthorDate: Thu Mar 11 17:36:24 2021 +0100

    database: Limit notifications to new failures and new successes.
---
 src/cuirass/database.scm | 48 ++++++++++++++++++++++++++----------------------
 1 file changed, 26 insertions(+), 22 deletions(-)

diff --git a/src/cuirass/database.scm b/src/cuirass/database.scm
index edbd193..5525114 100644
--- a/src/cuirass/database.scm
+++ b/src/cuirass/database.scm
@@ -528,6 +528,26 @@ RETURNING id;"))
   (failed-other      3)
   (canceled          4))
 
+(define-enumeration build-weather
+  (unknown          -1)
+  (new-success       0)
+  (new-failure       1)
+  (still-succeeding  2)
+  (still-failing     3))
+
+(define (build-status->weather status last-status)
+  (cond
+   ((or (< status 0) (not last-status))
+    (build-weather unknown))
+   ((and (= status 0) (> last-status 0))
+    (build-weather new-success))
+   ((and (> status 0) (= last-status 0))
+    (build-weather new-failure))
+   ((and (= status 0) (= last-status 0))
+    (build-weather still-succeeding))
+   ((and (> status 0) (> last-status 0))
+    (build-weather still-failing))))
+
 (define (db-add-output derivation output)
   "Insert OUTPUT associated with DERIVATION."
   (with-db-worker-thread db
@@ -771,8 +791,12 @@ UPDATE Builds SET stoptime =" now
                    (notifications
                     (specification-notifications specification)))
               (for-each (lambda (notif)
-                          (db-push-notification notif
-                                                (assq-ref build #:id)))
+                          (when (or (eq? weather
+                                         (build-weather new-success))
+                                    (eq? weather
+                                         (build-weather new-failure)))
+                            (db-push-notification notif
+                                                  (assq-ref build #:id))))
                         notifications)))))))
 
 (define* (db-update-build-worker! drv worker)
@@ -919,26 +943,6 @@ ORDER BY Builds.id DESC;"))
                          (#:buildproducts . ,(db-get-build-products id)))
                        result))))))))
 
-(define-enumeration build-weather
-  (unknown          -1)
-  (new-success       0)
-  (new-failure       1)
-  (still-succeeding  2)
-  (still-failing     3))
-
-(define (build-status->weather status last-status)
-  (cond
-   ((or (< status 0) (not last-status))
-    (build-weather unknown))
-   ((and (= status 0) (> last-status 0))
-    (build-weather new-success))
-   ((and (> status 0) (= last-status 0))
-    (build-weather new-failure))
-   ((and (= status 0) (= last-status 0))
-    (build-weather still-succeeding))
-   ((and (> status 0) (> last-status 0))
-    (build-weather still-failing))))
-
 (define (db-get-builds filters)
   "Retrieve all builds in the database which are matched by given FILTERS.
 FILTERS is an assoc list whose possible keys are 'derivation | 'id | 'jobset |



reply via email to

[Prev in Thread] Current Thread [Next in Thread]