diff options
Diffstat (limited to 'src/cuirass/http.scm')
-rw-r--r-- | src/cuirass/http.scm | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/cuirass/http.scm b/src/cuirass/http.scm index 7579e1a..2a4113f 100644 --- a/src/cuirass/http.scm +++ b/src/cuirass/http.scm @@ -136,6 +136,21 @@ Hydra format." (db-get-builds-by-search filters)))) (list->vector (map build->hydra-build builds)))) +(define (handle-events-request type filters) + "Retrieve all events of TYPE matched by FILTERS in the database." + (let ((events (with-time-logging + (simple-format #f "~A events request" type) + (db-get-events + `((type . ,type) + ,@filters))))) + `((items . ,(list->vector + (map (lambda (event) + `((id . ,(assq-ref event #:id)) + (timestamp . ,(assq-ref event #:timestamp)) + ,@(json-string->scm + (assq-ref event #:event_json)))) + events)))))) + (define (request-parameters request) "Parse the REQUEST query parameters and return them under the form '((parameter . value) ...)." @@ -366,6 +381,15 @@ Hydra format." ,@params (order . status+submission-time))))) (respond-json-with-error 500 "Parameter not defined!")))) + (("api" "build-events") + (let* ((params (request-parameters request)) + ;; 'nr parameter is mandatory to limit query size. + (valid-params? (assq-ref params 'nr))) + (if valid-params? + (respond-json + (object->json-string + (handle-events-request 'build params))) + (respond-json-with-error 500 "Parameter not defined!")))) (('GET) (respond-html (html-page "Cuirass" |