From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:8:6d80::]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id AD2fCvnremBZFwAAgWs5BA (envelope-from ) for ; Sat, 17 Apr 2021 16:08:57 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id eDRTBfnremCjWAAA1q6Kng (envelope-from ) for ; Sat, 17 Apr 2021 14:08:57 +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 9DEC0155EA for ; Sat, 17 Apr 2021 16:08:56 +0200 (CEST) Received: from localhost ([::1]:38114 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lXld1-0000Qa-OJ for larch@yhetil.org; Sat, 17 Apr 2021 10:08:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35092) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lXlcr-0000QC-52 for guix-devel@gnu.org; Sat, 17 Apr 2021 10:08:45 -0400 Received: from mout01.posteo.de ([185.67.36.65]:51953) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lXlco-0000Uo-Pb for guix-devel@gnu.org; Sat, 17 Apr 2021 10:08:44 -0400 Received: from submission (posteo.de [89.146.220.130]) by mout01.posteo.de (Postfix) with ESMTPS id B4F55240028 for ; Sat, 17 Apr 2021 16:08:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1618668519; bh=M0CBBlXj82kaiI3FBnOSsiTrdhqEbUWJCRCd/AolD/k=; h=Date:From:To:Cc:Subject:From; b=bZnt8fYnY7e8/h+CZzb3SN9yz/Mp1/Aa9veSjbV8o6qyQp5x5QU087vWbNsCsEKjm cWGb9fF4jirsB2OeGK/T2IZIazLy7r8o+4/Pemg7afNqV0/PUvwq+voplxAeiTElrw PhVTvVLP0lCICXRJ/eLgvG+/c9DZUBeAd+tbMc+xH0VPwwLrfKvxHmhirlOLZEyN4v 8sb4FM+hJzuLy7s6yy2x4rV7wtQTR0ZoKIOcjTnPZLk8xNWzue8ZsCCUwFD7FUTXR0 IfdUUUFe1S3A+umNj/vcS7ogW53EaGqCpJt6OJzfGuag9SffmlNpq4wDGa4ZezaPl1 MZkQVXs5xagRQ== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4FMw0j2l0yz9rxP; Sat, 17 Apr 2021 16:08:37 +0200 (CEST) Date: Sat, 17 Apr 2021 14:08:29 +0000 From: Luciana Lima Brito To: Christopher Baines Subject: Re: Outreachy - Guix Data Service: implementing basic json output for derivation comparison page Message-ID: <20210417110829.03ed516d@lubrito> In-Reply-To: <87bladjbsm.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> <20210416194735.0f4ccaed@lubrito> <877dl1xq15.fsf@cbaines.net> <20210417094857.14599c72@lubrito> <87bladjbsm.fsf@cbaines.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="MP_/EYfBrgW2ZkOJ/G0_SqPqOV4" Received-SPF: pass client-ip=185.67.36.65; envelope-from=lubrito@posteo.net; helo=mout01.posteo.de X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 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, FROM_FMBLA_NEWDOM=1.5, 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=no 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=1618668536; 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=5Y0kr4p/MmUMmyWkUnX+R+36qEc45TSyWDIyvcWCVUk=; b=K0haTP//aVG6kpAArc7Ogase3zxhFcFsMJi8z1Z5dDiywRBbY7IAspGWJNfkR8QPsv4vmX 5dZGd5t/COGcfuR1yjC7FtnHA5lo3yzsHoTZIHYyFaF1tHsltPifRCdK/BGPd4Eoy+KTf6 vnev9qsbdU/yF0jWD9Cpgx6Inyw7l3eHG/UvrjVC1jKLHmy4YjvHPDh4W+NqoUtVyG+T5K iHaYAGzdMneaqz2Y67GG19h6D99g4UL9+ImfGaQzVAtjgvZjOwsIDj5rqmtlYx8/UnltKW qGo6jnUiZ+3Vus+hrzXTnRC/89AyofGYLgXNkKLBilA+hDDYY2xZTxbYS0QDLQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1618668536; a=rsa-sha256; cv=none; b=Tw9HkVWA32/DYHdey6dfVgj+2XEFZycwzbgUZKFXgTfYteO8YhD3IHEw9EjAahJ8EBtaCx 71xSBC9t/omYb80EkZYHn3sV8Wnhp0HiGWy7g7PRRzZfAZbFskoXDXftdBw3A8hf+O5Npg /cRux6DNaFXGtcFouGmvpiFGQ+9hFVSb4ad4N/TxuBXqhzTsss1TjAgEwMXSLf8TbEBm6I jkEYRI5/Ow3p/HNOua215tBdb7VQ/9pV4zgi1Cft1ITAwx2hu0+zYo9uKRSAW7KEiRqm8y 28lzuR0S91zWiQZ9yGWzZaZHvxj6Yrp2wLyL7q4RoFDqAVPUcLCaQ7HIx39vGQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=bZnt8fYn; 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: -1.14 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=bZnt8fYn; 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: 9DEC0155EA X-Spam-Score: -1.14 X-Migadu-Scanner: scn0.migadu.com X-TUID: EzCpvdaUtiGr --MP_/EYfBrgW2ZkOJ/G0_SqPqOV4 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline On Sat, 17 Apr 2021 14:11:37 +0100 Christopher Baines wrote: Hi, > I think that's better, but you're still taking the matched-outputs, > matched-inputs and matched-sources alists, then later making the > values vectors rather than lists. The code would be even simpler if > you converted to a vector just after the map that produces the > relevant lists. > > I haven't looked to closely at the rest, but it looks like the > environment-variables binding is unnecessary, given how simple the bit > of code used is, it can just be inlined in the one place where the > binding is used. Done! :) I even simplified some other stuff, based on what you said. -- Best Regards, Luciana Lima Brito MSc. in Computer Science --MP_/EYfBrgW2ZkOJ/G0_SqPqOV4 Content-Type: text/x-patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=0001-Implement-basic-json-output-for-the-derivation-compa.patch >From 701c89e8f039a6bc7d9b616acded54eac26fb0a7 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 | 100 ++++++++++++++++++- 1 file changed, 97 insertions(+), 3 deletions(-) diff --git a/guix-data-service/web/compare/controller.scm b/guix-data-service/web/compare/controller.scm index a6aa198..14a25ee 100644 --- a/guix-data-service/web/compare/controller.scm +++ b/guix-data-service/web/compare/controller.scm @@ -588,9 +588,103 @@ '(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 + (list->vector + (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 '()))))) + '(base target common) + (list (assq-ref outputs 'base) + (assq-ref outputs 'target) + (assq-ref outputs 'common)))) + + (inputs (assq-ref data 'inputs)) + (matched-inputs + (map + (lambda (label items) + (cons label + (list->vector + (map + (match-lambda + ((derivation output) + `(,@(if (null? derivation) + '() + `((derivation . ,derivation))) + ,@(if (null? output) + '() + `((output . ,output)))))) + (or items '()))))) + '(base target common) + (list (assq-ref inputs 'base) + (assq-ref inputs 'target)))) + + (sources (assq-ref data 'sources)) + (matched-sources + (map + (lambda (label items) + (cons label + (list->vector + (map + (match-lambda + ((derivation) + `(,@(if (null? derivation) + '() + `((derivation . ,derivation)))))) + (or items '()))))) + '(base target common) + (list (assq-ref sources 'base) + (assq-ref sources 'target) + (assq-ref sources 'common)))) + + (args (assq-ref data 'arguments)) + (base-args (assq-ref args 'base)) + (target-args (assq-ref args 'target))) + + (render-json + `((base + . ((derivation . ,base-derivation))) + (target + . ((derivation . ,target-derivation))) + (outputs + . ,matched-outputs) + (inputs + . ,matched-inputs) + (sources + . ,matched-sources) + (system + . ,(assq-ref data 'system)) + (builder-and-arguments + . ((builder . ,(assq-ref data 'builder)) + (arguments + . ((base . ,(list->vector + base-args)) + (target . ,(list->vector + target-args)))))) + (environment-variables . ,(assq-ref data 'environment-variables))) + #:extra-headers http-headers-for-unchanging-content))) (else (render-html #:sxml (compare/derivation -- 2.30.2 --MP_/EYfBrgW2ZkOJ/G0_SqPqOV4--