From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id CGajB2YUemAsMgAAgWs5BA (envelope-from ) for ; Sat, 17 Apr 2021 00:49:10 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id 7kODAmYUemDMaQAAB5/wlQ (envelope-from ) for ; Fri, 16 Apr 2021 22:49:10 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 9F8D921206 for ; Sat, 17 Apr 2021 00:49:09 +0200 (CEST) Received: from localhost ([::1]:42288 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lXXGu-0004CN-P2 for larch@yhetil.org; Fri, 16 Apr 2021 18:49:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34064) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lXXGk-0004B6-Nd for guix-devel@gnu.org; Fri, 16 Apr 2021 18:48:58 -0400 Received: from mout01.posteo.de ([185.67.36.65]:42693) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lXXGh-0003GB-UA for guix-devel@gnu.org; Fri, 16 Apr 2021 18:48:58 -0400 Received: from submission (posteo.de [89.146.220.130]) by mout01.posteo.de (Postfix) with ESMTPS id 86D73240026 for ; Sat, 17 Apr 2021 00:48:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1618613333; bh=TPiZ2lKDbMXDcLOU7nmx5SC8M/enKuhEZ4ie19oQMWc=; h=Date:From:To:Cc:Subject:From; b=IUOk508jAt4c87R4PcrMylODDJWgaGMPr6Bxn5EozbSaSf0osRdQ1o/yusvdF4YSV lPiPQMTpVVUZ87rovZTJoGH0pTRxCrqwjjBACkYmDVpnU+IvzRADvo5gf4V1F1Hd1e QjLxVzMU3YS07I8Wn+bmB28ZA0GI0AiBbozZoSdLZ5gVnjoKEeuWz950SXq9l0q15N FW195fuFq5+BAl96aFw6+0TkCCrdR7w9sIKvEySa/w3LSMkaO4i7rXSHyWTWbMxdGP IW+kezixSKblO3Ksi3MkohPfGBuf9kHnO/kz/FuW/csVxUe9ItCfR9DSPCXpf60wq8 rlYmU41Ct92pQ== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4FMWZM4dqjz9rxR; Sat, 17 Apr 2021 00:47:55 +0200 (CEST) Date: Fri, 16 Apr 2021 22:47:35 +0000 From: Luciana Lima Brito To: Christopher Baines Subject: Re: Outreachy - Guix Data Service: implementing basic json output for derivation comparison page Message-ID: <20210416194735.0f4ccaed@lubrito> In-Reply-To: <87a6pyxcme.fsf@cbaines.net> References: <20210414164859.7acc631f@lubrito> <87wnt4x7e3.fsf@cbaines.net> <20210415130947.7387a546@lubrito> <87o8efxhil.fsf@cbaines.net> <20210416120740.05a819ca@lubrito> <87czuuxmdd.fsf@cbaines.net> <20210416154600.62c4a97d@lubrito> <87a6pyxcme.fsf@cbaines.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="MP_/Ri3Xs82OCrPYfAfLfkTiUwT" Received-SPF: pass client-ip=185.67.36.65; envelope-from=lubrito@posteo.net; helo=mout01.posteo.de X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guix-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: guix-devel@gnu.org Errors-To: guix-devel-bounces+larch=yhetil.org@gnu.org Sender: "Guix-devel" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1618613349; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=qwN2PYDEOBmpaIZ1LE6hHClHIIy8bXUa4vcW3rPv+to=; b=mWqmtZ6F4D8LciRVp6ZeAYsoE+lBXPhkATPV/65hxIdoAcLP3KNAOBFYnJY7Scg0wm5ocO NVsdmCQwRUydtmXLwrcMWn5+XnZpbgyLqlxZe+h9WwQK1dEtILyBrSHFJDfRgL/EeFQAcF LQVV19a8VidWqnJZx1AcIYUiuqYBraeu9n26UVzc+aME0rHDZwubwdu3UMBp62m3JuQFFi J/q9DKpo56QiKDXl5e6fYpgc7/Z8crEvPZbzokXsww8dhtKQqp9R8K97sdd5MCur2eq8eH K3VzBdfiGtpr37yriyJFVSOMKAjpSGdmw3ZN9IZxRBmnH2nejpmEBM0ND3+STA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1618613349; a=rsa-sha256; cv=none; b=Cm9akZBSuFAk3VNi0jhu7vXw9a92u66sg2R5jiURdTnaZWNEVuul/pe6sH2Aj3PFP4IFu4 ynh1AZWUFUyiO5APfsS0urjgWRegrqNe+Toz7ofsB8AhGH9jTnL9UdJkAQE/PNBgXWpoXB qbfLid6sVZY3CXZ4gVFGLByzwv158qu8ldu54fixOHfNWaraLJxBvwUM5X+0eFaKiQEAKU Rq15ApiXMbRd7kZBnJbUjSS+I6utI28wpYVeRenlFq2OkO2hSXU9SPl1dDxyC208aldk27 SOoYFxkSTBcdkoTzvbolnJklPND2/6k/4C+fTd1KxfWkd9mtWTEAa9Horpqmew== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=IUOk508j; dmarc=pass (policy=none) header.from=posteo.net; spf=pass (aspmx1.migadu.com: domain of guix-devel-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-devel-bounces@gnu.org X-Migadu-Spam-Score: -2.64 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=IUOk508j; dmarc=pass (policy=none) header.from=posteo.net; spf=pass (aspmx1.migadu.com: domain of guix-devel-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-devel-bounces@gnu.org X-Migadu-Queue-Id: 9F8D921206 X-Spam-Score: -2.64 X-Migadu-Scanner: scn0.migadu.com X-TUID: 2bWuYqGRkGCe --MP_/Ri3Xs82OCrPYfAfLfkTiUwT Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On Fri, 16 Apr 2021 20:17:45 +0100 Christopher Baines wrote: Hi, I hope the patch is correct this time. I considered all you said, so I separated the functions to get outputs, inputs and sources. I also implemented everything inside the case of the json/application. > While a flatter list is what you want when building an HTML table, I > think you were looking to get a JSON object separating the common, > base and target elements, right? If so, then map, rather than > append-map should be more useful to you here. Since above you're > passing in two lists of three things, if the procedure passed to map > returns a pair with a string in the first position, you'll end up > producing the scheme version of a JSON object (an alist). You were right about that, I'm using map now. Please, let me know if I missed something. Thanks in advance, I'm learning a great deal! :) --=20 Best Regards, Luciana Lima Brito MSc. in Computer Science Federal University of Uberl=C3=A2ndia --MP_/Ri3Xs82OCrPYfAfLfkTiUwT Content-Type: text/x-patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=0001-Implement-basic-json-output-for-the-derivation-compa.patch >From b51dd007180e69f7da479a857afd48dfa60e32e7 Mon Sep 17 00:00:00 2001 From: Luciana Brito Date: Sun, 11 Apr 2021 11:06:06 -0300 Subject: [PATCH] Implement basic json output for the derivation comparison page --- guix-data-service/web/compare/controller.scm | 122 ++++++++++++++++++- 1 file changed, 119 insertions(+), 3 deletions(-) diff --git a/guix-data-service/web/compare/controller.scm b/guix-data-service/web/compare/controller.scm index a6aa198..1b0fc2f 100644 --- a/guix-data-service/web/compare/controller.scm +++ b/guix-data-service/web/compare/controller.scm @@ -588,9 +588,125 @@ '(application/json text/html) mime-types) ((application/json) - (render-json - '((error . "unimplemented")) ; TODO - #:extra-headers http-headers-for-unchanging-content)) + (let* ((outputs (assq-ref data 'outputs)) + (matched-outputs + (map + (lambda (label items) + (cons label + (map + (match-lambda + ((name path hash-alg hash recursive) + `(,@(if (null? name) + '() + `((name . ,name))) + ,@(if (null? path) + '() + `((path . ,path)) + ) + ,@(if (or (null? hash-alg) (not (string? hash-alg))) + '() + `((hash-algorithm . ,hash-alg)) + ) + ,@(if (or (null? hash) (not (string? hash))) + '() + `((hash . ,hash)) + ) + ,@(if (null? recursive) + '() + `((recursive . ,(string=? recursive "t"))))))) + (or items '())))) + (list "base" "target" "common") + (list (assq-ref outputs 'base) + (assq-ref outputs 'target) + (assq-ref outputs 'common)))) + (base-outputs (list->vector (cdr (first matched-outputs)))) + (target-outputs (list->vector (cdr (second matched-outputs)))) + (common-outputs (list->vector (cdr (third matched-outputs)))) + + (inputs (assq-ref data 'inputs)) + (matched-inputs + (map + (lambda (label items) + (cons label + (map + (match-lambda + ((derivation output) + `(,@(if (null? derivation) + '() + `((derivation . ,derivation))) + ,@(if (null? output) + '() + `((output . ,output)))))) + (or items '())))) + (list "base" "target" "common") + (list (assq-ref inputs 'base) + (assq-ref inputs 'target)))) + (base-inputs (list->vector (cdr (first matched-inputs)))) + (target-inputs (list->vector (cdr (second matched-inputs)))) + + (sources (assq-ref data 'sources)) + (matched-sources + (map + (lambda (label items) + (cons label + (map + (match-lambda + ((derivation) + `(,@(if (null? derivation) + '() + `((derivation . ,derivation)))))) + (or items '())))) + (list "base" "target" "common") + (list (assq-ref sources 'base) + (assq-ref sources 'target) + (assq-ref sources 'common)))) + (base-sources (list->vector (cdr (first matched-sources)))) + (target-sources (list->vector (cdr (second matched-sources)))) + (common-sources (list->vector (cdr (third matched-sources)))) + + (system (assq-ref data 'system)) + (base-system (assq-ref system 'base)) + (target-system (assq-ref system 'target)) + (common-system (assq-ref system 'common)) + + (builder (assq-ref data 'builder)) + (base-builder (assq-ref builder 'base)) + (target-builder (assq-ref builder 'target)) + (common-builder (assq-ref builder 'common)) + + (args (assq-ref data 'arguments)) + (base-args (assq-ref args 'base)) + (target-args (assq-ref args 'target)) + (common-args (assq-ref args 'common)) + (environment-variables (assq-ref data 'environment-variables))) + + (render-json + `((base + . ((derivation . ,base-derivation))) + (target + . ((derivation . ,target-derivation))) + (outputs + . ((,(first (first matched-outputs)) . ,base-outputs) + (,(first (second matched-outputs)) . ,target-outputs) + (,(first (third matched-outputs)) . ,common-outputs))) + (inputs + . ((,(first (first matched-inputs)) . ,base-inputs) + (,(first (second matched-inputs)) . ,target-inputs))) + (sources + . ((,(first (first matched-sources)) . ,base-sources) + (,(first (second matched-sources)) . ,target-sources) + (,(first (third matched-sources)) . ,common-sources))) + (system + . ((common . ,common-system))) + (builder-and-arguments + . ((builder . ,common-builder) + (arguments + . ((base . ,(list->vector + base-args)) + (target . ,(list->vector + target-args)))))) + (environment-variables . ,environment-variables)) + #:extra-headers http-headers-for-unchanging-content))) (else (render-html #:sxml (compare/derivation -- 2.30.2 --MP_/Ri3Xs82OCrPYfAfLfkTiUwT--