http: Factorize ‘checkout->json-object’.

* src/cuirass/http.scm (checkout->json-object): New procedure.
(evaluation->json-object): Use it.
This commit is contained in:
Ludovic Courtès 2023-10-01 16:10:04 +02:00
parent 0ebd0b632e
commit d1486d71be
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
1 changed files with 8 additions and 4 deletions

View File

@ -138,6 +138,13 @@
(file-size . ,(build-product-file-size product))))
(build-products build))))))
(define (checkout->json-object checkout)
"Return an alist suitable for 'json->scm' representing CHECKOUT,
a <checkout> record."
`((commit . ,(checkout-commit checkout))
(channel . ,(checkout-channel checkout))
(directory . ,(checkout-directory checkout))))
(define (evaluation->json-object evaluation)
"Turn EVALUATION into a representation suitable for 'json->scm'."
`((id . ,(evaluation-id evaluation))
@ -148,10 +155,7 @@
(evaltime . ,(evaluation-start-time evaluation))
(checkouts
. ,(list->vector
(map (lambda (checkout)
`((commit . ,(checkout-commit checkout))
(channel . ,(checkout-channel checkout))
(directory . ,(checkout-directory checkout))))
(map checkout->json-object
;; Get the complete lists of checkouts, not just those that are
;; different from the previous evaluation.