From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christopher Baines Subject: [PATCH 2/2] Support publishing evaluation events Date: Mon, 28 Oct 2019 08:10:26 +0000 Message-ID: <20191028081026.25988-2-mail@cbaines.net> References: <8736fjqbrd.fsf@cbaines.net> <20191028081026.25988-1-mail@cbaines.net> Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:51152) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iP06h-000813-GJ for guix-devel@gnu.org; Mon, 28 Oct 2019 04:10:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iP06g-00046b-23 for guix-devel@gnu.org; Mon, 28 Oct 2019 04:10:31 -0400 Received: from mira.cbaines.net ([2a01:7e00::f03c:91ff:fe69:8da9]:46210) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1iP06f-00042p-Sf for guix-devel@gnu.org; Mon, 28 Oct 2019 04:10:30 -0400 Received: from localhost (cpc102582-walt20-2-0-cust14.13-2.cable.virginm.net [86.27.34.15]) by mira.cbaines.net (Postfix) with ESMTPSA id 92987175DB for ; Mon, 28 Oct 2019 08:10:27 +0000 (GMT) Received: from localhost (localhost [local]) by localhost (OpenSMTPD) with ESMTPA id f640d42a for ; Mon, 28 Oct 2019 08:10:26 +0000 (UTC) In-Reply-To: <20191028081026.25988-1-mail@cbaines.net> List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: guix-devel@gnu.org --- src/cuirass/base.scm | 5 +++++ src/cuirass/database.scm | 6 +++++- src/cuirass/http.scm | 9 +++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/cuirass/base.scm b/src/cuirass/base.scm index fd10e35..943a4f2 100644 --- a/src/cuirass/base.scm +++ b/src/cuirass/base.scm @@ -724,6 +724,11 @@ started)." (checkouts (fetch-inputs spec)) (eval-id (db-add-evaluation name checkouts))) (when eval-id + (db-add-event 'evaluation + (time-second (current-time time-utc)) + `((#:evalutaion . ,eval-id) + (#:specification . ,name) + (#:in_progress . #t))) (compile-checkouts spec (filter compile? checkouts)) (spawn-fiber (lambda () diff --git a/src/cuirass/database.scm b/src/cuirass/database.scm index 83c0c5a..05382d7 100644 --- a/src/cuirass/database.scm +++ b/src/cuirass/database.scm @@ -408,7 +408,11 @@ VALUES (" spec-name ", true);") (define (db-set-evaluation-done eval-id) (with-db-critical-section db (sqlite-exec db "UPDATE Evaluations SET in_progress =3D false -WHERE id =3D " eval-id ";"))) +WHERE id =3D " eval-id ";") + (db-add-event 'evaluation + (time-second (current-time time-utc)) + `((#:evaluation . ,eval-id) + (#:in_progress . #f))))) =20 (define-syntax-rule (with-database body ...) "Run BODY with %DB-CHANNEL being dynamically bound to a channel implem= enting diff --git a/src/cuirass/http.scm b/src/cuirass/http.scm index 35e3d7f..4a3214d 100644 --- a/src/cuirass/http.scm +++ b/src/cuirass/http.scm @@ -347,6 +347,15 @@ Hydra format." (specifications-table (db-get-specifications)) '()))) + (("api" "evaluation-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 'evaluation params))) + (respond-json-with-error 500 "Parameter not defined!")))) =20 (("jobset" name) (respond-html --=20 2.23.0