[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Mathieu Othacehe |
Date: |
Tue, 15 Sep 2020 08:34:48 -0400 (EDT) |
branch: master
commit 97ec7a2da52e093234576b0e65b18c6db4411bde
Author: Mathieu Othacehe <othacehe@gnu.org>
AuthorDate: Tue Sep 15 11:13:09 2020 +0200
metrics: Add 'new-derivations-per-day support.
* src/cuirass/metrics.scm (db-new-derivations-previous-day): New procedure.
(%metrics): Add 'new-derivations-per-day.
(db-update-metrics): Add it.
* src/cuirass/templates.scm (make-line-chart): Add support for multiple
datasets. Also add "interpolation?" and "legend?" options.
(global-metrics-content): Add "new-derivations-per-day" argument. Adapt
"Builds per day" chart so that it uses two datasets from
'new-derivations-per-day and 'builds-per-day metrics.
* src/cuirass/templates.scm (url-handler): Adapt accordingly.
---
src/cuirass/http.scm | 4 ++++
src/cuirass/metrics.scm | 15 ++++++++++++++-
src/cuirass/templates.scm | 38 ++++++++++++++++++++++++++++----------
3 files changed, 46 insertions(+), 11 deletions(-)
diff --git a/src/cuirass/http.scm b/src/cuirass/http.scm
index 6b20a2b..b9f1eb6 100644
--- a/src/cuirass/http.scm
+++ b/src/cuirass/http.scm
@@ -613,6 +613,9 @@ Hydra format."
(let ((builds-per-day
(db-get-metrics-with-id 'builds-per-day
#:limit 10))
+ (new-derivations-per-day
+ (db-get-metrics-with-id 'new-derivations-per-day
+ #:limit 10))
(pending-builds
(db-get-metrics-with-id 'pending-builds
#:limit 10))
@@ -627,6 +630,7 @@ Hydra format."
(global-metrics-content
#:avg-eval-durations avg-eval-durations
#:builds-per-day builds-per-day
+ #:new-derivations-per-day new-derivations-per-day
#:pending-builds pending-builds))
'())))
diff --git a/src/cuirass/metrics.scm b/src/cuirass/metrics.scm
index cd4e901..f6fcd7f 100644
--- a/src/cuirass/metrics.scm
+++ b/src/cuirass/metrics.scm
@@ -69,6 +69,12 @@ FROM Evaluations WHERE specification = " spec
WHERE date(timestamp, 'unixepoch') = date('now', '-1 day') AND
date(stoptime, 'unixepoch') = date('now', '-1 day');")))
(and=> (expect-one-row rows) (cut vector-ref <> 0)))))
+
+(define (db-new-derivations-previous-day _)
+ "Return the new derivations count of the previous day."
+ (with-db-worker-thread db
+ (let ((rows (sqlite-exec db "SELECT COUNT(*) from Builds
+WHERE date(timestamp, 'unixepoch') = date('now', '-1 day');")))
(and=> (expect-one-row rows) (cut vector-ref <> 0)))))
(define (db-pending-builds _)
@@ -122,7 +128,13 @@ date('now'));")))
(metric
(id 'pending-builds)
(compute-proc db-pending-builds)
- (field-proc db-current-day-timestamp))))
+ (field-proc db-current-day-timestamp))
+
+ ;; New derivations per day.
+ (metric
+ (id 'new-derivations-per-day)
+ (compute-proc db-new-derivations-previous-day)
+ (field-proc db-previous-day-timestamp))))
(define (metric->type metric)
"Return the index of the given METRIC in %metrics list. This index is used
@@ -209,6 +221,7 @@ timestamp) VALUES ("
(map (cut assq-ref <> #:name) (db-get-specifications)))
(db-update-metric 'builds-per-day)
+ (db-update-metric 'new-derivations-per-day)
(db-update-metric 'pending-builds)
;; Update specification related metrics.
diff --git a/src/cuirass/templates.scm b/src/cuirass/templates.scm
index 4f1a278..3491d3b 100644
--- a/src/cuirass/templates.scm
+++ b/src/cuirass/templates.scm
@@ -826,10 +826,13 @@ and BUILD-MAX are global minimal and maximal row
identifiers."
(tbody
,(map build-row builds)))))))
-(define* (make-line-chart id data
+(define* (make-line-chart id datasets
#:key
+ (interpolation? #t)
+ (legend? #f)
title
- color)
+ labels
+ colors)
(let* ((scales `((xAxes
. ,(vector '((type . "time")
(time . ((unit . "day")))
@@ -844,12 +847,20 @@ and BUILD-MAX are global minimal and maximal row
identifiers."
. ((display . #t)
(labelString . "Builds"))))))))
(chart `((type . "line")
- (data . ((datasets . ,(vector `((fill . #f)
- (borderColor . ,color)
- (data . ,data))))))
+ (data . ((datasets
+ . ,(apply vector
+ (map (lambda (dataset label color)
+ `((fill . #f)
+ (label . ,label)
+ ,@(if interpolation?
+ '()
+ '((lineTension . 0)))
+ (borderColor . ,color)
+ (data . ,dataset)))
+ datasets labels colors)))))
(options . ((responsive . #t)
(tooltips . ((enabled . #f)))
- (legend . ((display . #f)))
+ (legend . ((display . ,legend?)))
(title . ((display . #t)
(text . ,title)))
(scales . ,scales))))))
@@ -862,6 +873,7 @@ window.~a = new Chart\
(define* (global-metrics-content #:key
avg-eval-durations
builds-per-day
+ new-derivations-per-day
pending-builds)
(define (avg-eval-duration-row . eval-durations)
(let ((spec (match eval-durations
@@ -901,10 +913,16 @@ window.~a = new Chart\
;; Scripts.
(script (@ (src "/static/js/chart.js")))
,@(make-line-chart builds-chart
- (builds->json-scm builds-per-day)
+ (list (builds->json-scm new-derivations-per-day)
+ (builds->json-scm builds-per-day))
+ #:interpolation? #f
#:title "Builds per day"
- #:color "#3e95cd")
+ #:legend? #t
+ #:labels '("New derivations"
+ "Builds completed")
+ #:colors (list "#f6dd27" "#3e95cd"))
,@(make-line-chart pending-builds-chart
- (builds->json-scm pending-builds)
+ (list (builds->json-scm pending-builds))
#:title "Pending builds"
- #:color "#3e95cd")))))
+ #:labels '("Pending builds")
+ #:colors (list "#3e95cd"))))))
- master updated (cf11b73 -> f3ab04a), Mathieu Othacehe, 2020/09/15
- [no subject], Mathieu Othacehe, 2020/09/15
- [no subject], Mathieu Othacehe, 2020/09/15
- [no subject],
Mathieu Othacehe <=
- [no subject], Mathieu Othacehe, 2020/09/15
- [no subject], Mathieu Othacehe, 2020/09/15
- [no subject], Mathieu Othacehe, 2020/09/15
- [no subject], Mathieu Othacehe, 2020/09/15
- [no subject], Mathieu Othacehe, 2020/09/15
- [no subject], Mathieu Othacehe, 2020/09/15