diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/cuirass/http.scm | 23 | ||||
-rw-r--r-- | src/cuirass/utils.scm | 4 |
2 files changed, 21 insertions, 6 deletions
diff --git a/src/cuirass/http.scm b/src/cuirass/http.scm index b69b6ce..a26b1c6 100644 --- a/src/cuirass/http.scm +++ b/src/cuirass/http.scm @@ -105,6 +105,14 @@ (#:releasename . #nil) (#:buildinputs_builds . #nil))) +(define (evaluation->json-object evaluation) + "Turn EVALUATION into a representation suitable for 'json->scm'." + ;; XXX: Since #:checkouts is a list of alists, we must turn it into a vector + ;; so that 'json->scm' converts it to a JSON array. + `(,@(alist-delete #:checkouts evaluation eq?) + (#:checkouts . ,(list->vector + (assq-ref evaluation #:checkouts))))) + (define (handle-build-request build-id) "Retrieve build identified by BUILD-ID over the database and convert it to hydra format. Return #f is not build was found." @@ -116,14 +124,14 @@ hydra format. Return #f is not build was found." Hydra format." (let ((builds (with-time-logging "builds request" (db-get-builds filters)))) - (map build->hydra-build builds))) + (list->vector (map build->hydra-build builds)))) (define (handle-builds-search-request filters) "Retrieve all builds matched by FILTERS in the database and convert them to Hydra format." (let ((builds (with-time-logging "builds search request" (db-get-builds-by-search filters)))) - (map build->hydra-build builds))) + (list->vector (map build->hydra-build builds)))) (define (request-parameters request) "Parse the REQUEST query parameters and return them under the form @@ -233,7 +241,8 @@ Hydra format." (request-path-components request) 'method-not-allowed) (((or "jobsets" "specifications") . rest) - (respond-json (object->json-string (db-get-specifications)))) + (respond-json (object->json-string + (list->vector (db-get-specifications))))) (("build" build-id) (let ((hydra-build (handle-build-request (string->number build-id)))) (if hydra-build @@ -274,7 +283,10 @@ Hydra format." ;; 'nr parameter is mandatory to limit query size. (nr (assq-ref params 'nr))) (if nr - (respond-json (object->json-string (db-get-evaluations nr))) + (respond-json (object->json-string + (list->vector + (map evaluation->json-object + (db-get-evaluations nr))))) (respond-json-with-error 500 "Parameter not defined!")))) (("api" "latestbuilds") (let* ((params (request-parameters request)) @@ -304,7 +316,8 @@ Hydra format." ('() (respond-html (html-page "Cuirass" - (specifications-table (db-get-specifications)) + (specifications-table + (list->vector (db-get-specifications))) '()))) (("jobset" name) diff --git a/src/cuirass/utils.scm b/src/cuirass/utils.scm index 48e797c..fe74b69 100644 --- a/src/cuirass/utils.scm +++ b/src/cuirass/utils.scm @@ -1,5 +1,5 @@ ;;; utils.scm -- helper procedures -;;; Copyright © 2012, 2013, 2016, 2018 Ludovic Courtès <ludo@gnu.org> +;;; Copyright © 2012, 2013, 2016, 2018, 2019 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2015 David Thompson <davet@gnu.org> ;;; Copyright © 2016 Mathieu Lirzin <mthl@gnu.org> ;;; Copyright © 2018 Clément Lassieur <clement@lassieur.org> @@ -57,6 +57,8 @@ ((null? obj) obj) ((symbol? obj) (symbol->string obj)) ((keyword? obj) (object->json-scm (keyword->symbol obj))) + ((vector? obj) (list->vector + (map object->json-scm (vector->list obj)))) ((alist? obj) (map object->json-scm obj)) ((pair? obj) (cons (object->json-scm (car obj)) (object->json-scm (cdr obj)))) |