From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id cGZaFQ2OfWAmOQAAgWs5BA (envelope-from ) for ; Mon, 19 Apr 2021 16:05:01 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id MNUHEQ2OfWDLIAAA1q6Kng (envelope-from ) for ; Mon, 19 Apr 2021 14:05:01 +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 CA56827A11 for ; Mon, 19 Apr 2021 16:05:00 +0200 (CEST) Received: from localhost ([::1]:45240 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lYUWJ-0000zD-MC for larch@yhetil.org; Mon, 19 Apr 2021 10:04:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59062) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lYUW1-0000q4-3F for guix-devel@gnu.org; Mon, 19 Apr 2021 10:04:41 -0400 Received: from mout01.posteo.de ([185.67.36.65]:38679) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lYUVy-0001Kc-C6 for guix-devel@gnu.org; Mon, 19 Apr 2021 10:04:40 -0400 Received: from submission (posteo.de [89.146.220.130]) by mout01.posteo.de (Postfix) with ESMTPS id 1E2BA24002C for ; Mon, 19 Apr 2021 16:04:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1618841075; bh=7o+9fCsRqR0Vq/yY09CHkb/emRFg3pbzxfpXr+9wB7Q=; h=Date:From:To:Cc:Subject:From; b=qhqRv+FzKOdeypbnUObMx5Lz7Y95g/eTV/N4Bj+FfblT7GuoGhE+agH7yJxf9dSgT e2W/dDBBpMQmPMNwJakHQqZ3m7z2bVHFeAC/8X26UWZ/mtQBCto2dcx9r8pKY8K9c8 azAGVfOpb1QFf0Han1cFvSH2AsEEgkB6/4DQjyNLruATG1JdPmVnTfx7SGmQMYmmAu Pl28mQ7S+LYprtpl8cQDcLa6G0cnijLeunuAbE/Jjb9AJ/3clWXOvHUFCbQ6nDXYA1 VDwZXq7ceF+XGY4U62iJ5zqrnOIWyQw+TqTobDrBSVGKdOFJrZMl30Z21oLEU/olls MHdYPRwN/qzrA== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4FP7q45pXxz6tmY; Mon, 19 Apr 2021 16:04:32 +0200 (CEST) Date: Mon, 19 Apr 2021 14:04:24 +0000 From: Luciana Lima Brito To: Christopher Baines Subject: Re: Outreachy - Guix Data Service: implementing basic json output for derivation comparison page Message-ID: <20210419110425.7bd26e41@lubrito> In-Reply-To: <87r1j6ist6.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> <20210417110829.03ed516d@lubrito> <875z0kkdp1.fsf@cbaines.net> <20210418101207.3ad239ae@lubrito> <87zgxvimbe.fsf@cbaines.net> <20210418161230.72ecae02@lubrito> <87r1j6ist6.fsf@cbaines.net> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="MP_/EWcmzYF/pSyOFHA3uQYwf37" 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.499, 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=1618841101; 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=TFCgNWmP3QkbmWibLoHnSXb5FeqoU3pwRK5wj4dUdbU=; b=gokevP1pQ0iwKdLmBq6qKlHkjkJVyoKSSB2To46aGKB3n+qew9D0ZTg6U53yRf0IndRHb0 iwiTk8XohtbDyQDkjCNDXNBt3PQa0toVIxpVxo1YpwaCya6n7IVaHO0AkJXGD0d7ZpaVVc 39coq7C+LbL/hKuIyAJVSdGWYia+cV1ksEYZc5jwKzuowqDP8PwygaH9emBA2kNa/ZPahQ fUnCXl+kAaWY51l5/2ntuV69VPb2B6EB1BQbcfzmY9k01uJfoYLkbBmhESpTnt5+zmvNxt sbzRDZIDOoTMjubiqgPBwwusNX/gFkcSnlIQojMGei1BHp6gOz+wd9by28H3MA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1618841101; a=rsa-sha256; cv=none; b=XvU6KSofeVwoiznKtRtxS2/kA8+Nzn5xNEs1OZtLWmpN5LMCs7kS04fCdpaOp13Qg6k2LM WrTc/kpPC4YM/0nY91Q6XUP2teGhSm3WyvTtGnNXXSehkPQ7ysejcNTKwE9M65rO7S7WAn ndx+hgv68us9+EiPq1j9q8hdEpVCeysuRv5G8/yIaby2Cr+8nBT4fpaJpOjYK4qU/Xjzja U7GRpj8nzrGH4XnFwO1ipALdOeDUCWsCZOsZ4t0YDXJADcLkD2wX1zcdxx2cgNbtSJDggm AMpmNECoJpcz6ARLk2Oei8lnC7uLyOhN/1p+vFGTSS+/CTCvIZQLB4yKyy6Y/w== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=qhqRv+Fz; 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: -3.26 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=qhqRv+Fz; 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: CA56827A11 X-Spam-Score: -3.26 X-Migadu-Scanner: scn0.migadu.com X-TUID: UnmOn43lgB2m --MP_/EWcmzYF/pSyOFHA3uQYwf37 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline On Mon, 19 Apr 2021 09:26:13 +0100 Christopher Baines wrote: > As an example, if you have this structure. > > '((foo . 1) > (bar . 2)) > > and you want the numbers to be strings, you can do something like: > > (map (match-lambda > ((name . number) > (cons name (number->string number)))) > data) > > and I think a similar approach for the transformation you're trying to > perform to the arguments will more cleanly represent what you're > trying to do. It helped a lot! > One different thing I noticed: > > ,@(if (not (string? hash-alg)) > '() > `((hash-algorithm . ,hash-alg))) > > I'd suggest simplifying this by flipping the different parts of the > if, and removing the not. Done. -- Best Regards, Luciana Lima Brito MSc. in Computer Science --MP_/EWcmzYF/pSyOFHA3uQYwf37 Content-Type: text/x-patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=0001-Implement-basic-json-output-for-the-derivation-compa.patch >From ce5d97dd490f6ffb58548e83be78af576404b01f 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 | 85 +++++++++++++++++++- 1 file changed, 82 insertions(+), 3 deletions(-) diff --git a/guix-data-service/web/compare/controller.scm b/guix-data-service/web/compare/controller.scm index a6aa198..85fcbe9 100644 --- a/guix-data-service/web/compare/controller.scm +++ b/guix-data-service/web/compare/controller.scm @@ -588,9 +588,88 @@ '(application/json text/html) mime-types) ((application/json) - (render-json - '((error . "unimplemented")) ; TODO - #:extra-headers http-headers-for-unchanging-content)) + (let ((outputs + (map + (lambda (label items) + (cons label + (list->vector + (map + (match-lambda + ((name path hash-alg hash recursive) + `((name . ,name) + (path . ,path) + ,@(if (string? hash-alg) + `((hash-algorithm . ,hash-alg)) + '()) + ,@(if (string? hash) + `((hash . ,hash)) + '()) + (recursive . ,(string=? recursive "t"))))) + (or items '()))))) + '(base target common) + (let ((output-groups (assq-ref data 'outputs))) + (list (assq-ref output-groups 'base) + (assq-ref output-groups 'target) + (assq-ref output-groups 'common))))) + + (inputs + (map + (lambda (label items) + (cons label + (list->vector + (map + (match-lambda + ((derivation output) + `((derivation . ,derivation) + (output . ,output)))) + (or items '()))))) + '(base target common) + (let ((input-groups (assq-ref data 'inputs))) + (list (assq-ref input-groups 'base) + (assq-ref input-groups 'target) + (assq-ref input-groups 'common))))) + + (sources + (map + (lambda (label items) + (cons label + (list->vector + (map + (match-lambda + ((derivation) + `((derivation . ,derivation)))) + (or items '()))))) + '(base target common) + (let ((source-groups (assq-ref data 'sources))) + (list (assq-ref source-groups 'base) + (assq-ref source-groups 'target) + (assq-ref source-groups 'common))))) + + (arguments + (map + (match-lambda + ((label args ...) + `(,label . ,(list->vector args)))) + (assq-ref data 'arguments)))) + + (render-json + `((base + . ((derivation . ,base-derivation))) + (target + . ((derivation . ,target-derivation))) + (outputs + . ,outputs) + (inputs + . ,inputs) + (sources + . ,sources) + (system + . ,(assq-ref data 'system)) + (builder + . ,(assq-ref data 'builder)) + (arguments . ,arguments) + (environment-variables . ,(assq-ref data 'environment-variables))) + #:extra-headers http-headers-for-unchanging-content))) (else (render-html #:sxml (compare/derivation -- 2.30.2 --MP_/EWcmzYF/pSyOFHA3uQYwf37--