branch: main
commit dea68d4e795d8f4852f743ca8d4d3026ab6021a6
Author: Ludovic Courtès <[email protected]>
AuthorDate: Sun Jan 5 19:25:31 2025 +0100
templates: metrics: Show pending builds per system.
* src/cuirass/templates.scm (bright-color): New procedure.
(global-metrics-content): Add #:pending-builds-per-system. Add it to
‘pending-builds-chart’. Pass #:legend? #t and adjust the dataset
argument, #:labels, and #:colors to include all the systems.
* src/cuirass/http.scm (metrics-page): Pass #:pending-builds-per-system.
---
src/cuirass/http.scm | 8 +++++++-
src/cuirass/templates.scm | 21 +++++++++++++++++----
2 files changed, 24 insertions(+), 5 deletions(-)
diff --git a/src/cuirass/http.scm b/src/cuirass/http.scm
index 25b9074..a943b2c 100644
--- a/src/cuirass/http.scm
+++ b/src/cuirass/http.scm
@@ -1,7 +1,7 @@
;;;; http.scm -- HTTP API
;;; Copyright © 2016 Mathieu Lirzin <[email protected]>
;;; Copyright © 2017, 2020, 2021 Mathieu Othacehe <[email protected]>
-;;; Copyright © 2018-2020, 2023-2024 Ludovic Courtès <[email protected]>
+;;; Copyright © 2018-2020, 2023-2025 Ludovic Courtès <[email protected]>
;;; Copyright © 2018 Clément Lassieur <[email protected]>
;;; Copyright © 2018 Tatiana Sholokhova <[email protected]>
;;; Copyright © 2019, 2020 Ricardo Wurmus <[email protected]>
@@ -363,6 +363,12 @@ Hydra format."
#:pending-builds
(db-get-metrics-with-id 'pending-builds
#:limit 100)
+ #:pending-builds-per-system
+ (map (lambda (system)
+ (db-get-metrics-with-id 'pending-builds-per-system
+ #:value system
+ #:limit 100))
+ %cuirass-supported-systems)
#:percentage-failed-eval
(list
(db-get-metrics-with-id
diff --git a/src/cuirass/templates.scm b/src/cuirass/templates.scm
index ef7e241..6f3c2d1 100644
--- a/src/cuirass/templates.scm
+++ b/src/cuirass/templates.scm
@@ -1,6 +1,6 @@
;;; templates.scm -- HTTP API
;;; Copyright © 2018 Tatiana Sholokhova <[email protected]>
-;;; Copyright © 2018-2021, 2023-2024 Ludovic Courtès <[email protected]>
+;;; Copyright © 2018-2021, 2023-2025 Ludovic Courtès <[email protected]>
;;; Copyright © 2019, 2020 Ricardo Wurmus <[email protected]>
;;; Copyright © 2020 Mathieu Othacehe <[email protected]>
;;;
@@ -1941,6 +1941,13 @@ window.~a = new Chart\
});" id id (string-replace-substring
(scm->json-string chart) "\"" "'"))))))
+(define (bright-color str)
+ "Compute a bright color based on STR."
+ (let ((hash (string-hash str (expt 2 24))))
+ (if (or (< hash #x303030) (> hash #xd0d0d0))
+ (bright-color (string-append str "+"))
+ (format #f "#~6'0x" hash))))
+
(define* (global-metrics-content #:key
avg-eval-durations
avg-eval-build-start-time
@@ -1949,6 +1956,7 @@ window.~a = new Chart\
eval-completion-speed
new-derivations-per-day
pending-builds
+ pending-builds-per-system
percentage-failed-eval)
(define (avg-eval-duration-row . eval-durations)
(let ((spec (match eval-durations
@@ -2094,13 +2102,18 @@ completed builds divided by the time required to build
them.")
#:labels '("Completion speed")
#:colors (list "#3e95cd"))
,@(make-line-chart pending-builds-chart
- (list (builds->json-scm pending-builds))
+ (cons (builds->json-scm pending-builds)
+ (map builds->json-scm
+ pending-builds-per-system))
#:time-x-axes? #t
#:x-label "Day"
#:y-label "Builds"
#:title "Pending builds"
- #:labels '("Pending builds")
- #:colors (list "#3e95cd")))))
+ #:legend? #t
+ #:labels (cons "Total" %cuirass-supported-systems)
+ #:colors (cons "#3e95cd"
+ (map bright-color
+ %cuirass-supported-systems))))))
(define system->color-class
(let ((alist (map cons