From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:bcc0::]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id AHAyOrqEfGD7aQEAgWs5BA (envelope-from ) for ; Sun, 18 Apr 2021 21:12:58 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id GJzLNLqEfGAHJQAAB5/wlQ (envelope-from ) for ; Sun, 18 Apr 2021 19:12:58 +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 906B01AFFC for ; Sun, 18 Apr 2021 21:12:58 +0200 (CEST) Received: from localhost ([::1]:48702 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lYCqn-000518-LW for larch@yhetil.org; Sun, 18 Apr 2021 15:12:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36594) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lYCqb-0004zL-6R for guix-devel@gnu.org; Sun, 18 Apr 2021 15:12:45 -0400 Received: from mout01.posteo.de ([185.67.36.65]:40513) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lYCqZ-0002NQ-3p for guix-devel@gnu.org; Sun, 18 Apr 2021 15:12:44 -0400 Received: from submission (posteo.de [89.146.220.130]) by mout01.posteo.de (Postfix) with ESMTPS id D29CB240026 for ; Sun, 18 Apr 2021 21:12:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1618773161; bh=vgL47euFqGHR9oi2xe29YTpw13pBYmbnsD83tEcYvnc=; h=Date:From:To:Cc:Subject:From; b=f5no7yMp3zvHyKdCUDFF4oXv3fIULrjilOal6SbQvYiVigZ22elA/HMhnkNfb0h94 xvw4gMIcsrLn7SDdMDThz9nxE9BKss1CyaVzdRhN/1GbZHQMuWxk++AYhCs0tPTck0 uKeeRGiIo40vdYYsh/8vt/ZqPxF++5BH2InDhxRwe9l2hoSCjf7C+mT1/YIfh/Mnw+ Bmh4QKXzrwoOtk/QwtaI1I4DzgLm2pyvFZIrZW4vOsFFFFbl0Rk9XiS0Se1ELvhen/ HzvZqbn7q6v48HNbbkyOjtRmqn8ipHz80jdPDdyMFkFZ+xDA0KfusNV0coixQHqt/G ZsP/xiOeDOjFQ== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4FNfj32HTHz6tmT; Sun, 18 Apr 2021 21:12:38 +0200 (CEST) Date: Sun, 18 Apr 2021 19:12:30 +0000 From: Luciana Lima Brito To: Christopher Baines Subject: Re: Outreachy - Guix Data Service: implementing basic json output for derivation comparison page Message-ID: <20210418161230.72ecae02@lubrito> In-Reply-To: <87zgxvimbe.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> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="MP_/aPblJcGTM6gUG83M5lrY34K" 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.01, RCVD_IN_MSPIKE_WL=-0.01, 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=1618773178; 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=lJg9UhbTpTPJzqKaetXxK0+kbiBGav5FcN86Y1Rfpvc=; b=nZdRSrxvpFnv7gy88SR5VchOuemIQrYJAO3tlytDMqluNUtcvMlTEF7J6wwnWK6s41SSsH DQY67mICNSleO5JlGkK608hQ1sGQcfmuzeT+97Yf10lKassLuYuulqXc+/QVAm9gbMdnik /Hi8Oi5ZIfHNsb9lmjHOZ/mLRjsX79+/XHoK7zyJ7O+Y1517BGC+wYl8lfQvn2ZhgbxAXN Z3myOvtjcAVjE5kAQ97Bi3PmnU7B7QWCixpVWbJJued6GvvJqzPa9xj/2HPBuQUuoRZlv4 bxPhcOXiLzb/TuFB1Xs8oVsMgQsNalsnI4E/XR/Gpq0XGiDz6aYbB68UHIr3Dw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1618773178; a=rsa-sha256; cv=none; b=asMN59QsFbgAD7GO0hWoiU2l6ggsa9+3oB78Lekdhc/fBn+R/bDgGcWKwiUZzb3K8ZqVwq naxGMAN0Ox8imjLc0Pdgb+abzyVh9RwTh7UZznlpAwpVVFjJFUCCd7tpcFRzRYsuzn2Mq9 trIIn1DO3yeAobRMDlNSt5rRdMH5VyUkHsxushjFKrPSPRb8LnLK1cndWjzIXYPIYPF1AO ehAimfTMiOeDNLPi620aLQMJynEPMem1C2EKshYstUfEYnqwKC9g0t46FApKV2DbCyOydi s9tPoMJc6yBtXibFX99zkLLO7b9qwQk2UlP/F6M0Vx58OIhtLKrvy/Lh3rHHUw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=f5no7yMp; 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=f5no7yMp; 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: 906B01AFFC X-Spam-Score: -2.64 X-Migadu-Scanner: scn0.migadu.com X-TUID: 9BnJfrBXtiRg --MP_/aPblJcGTM6gUG83M5lrY34K Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi, On Sun, 18 Apr 2021 17:34:13 +0100 Christopher Baines wrote: > I think it might be good to do something, just to narrow the scope. > The outputs binding is valid for the whole let*, and all the code in > it, but is only used on three lines, in one single place. Maybe there > could be a let there that just defines outputs (maybe named > output-groups so you can use the outputs binding for the overall > thing). I did it. > That's a good question, I'd look at the database schema, assuming the > type of the field is a boolean, the question is whether the field is > nullable? I looked on the database schema, and the "recursive" field is not nullable, and it is a boolean, so the test I'm doing is working for this. > Hmm, I'm not sure why that is on the HTML page, but I'd generally try > and keep most bits in the JSON, since it's not as helpful to omit bits > if they're not that important. I added the "common" field for inputs. > > One other thing I noticed is that the alist for the args is being > picked apart then reconstructed. Like for the inputs, outputs and > sources, I'd map over the arguments alist and transform it to the way > you want it to be. This part was a bit more complicated for me to understand. You mean I should build a function similar to outputs, inputs and sources to map the arguments, wouldn't it be a lot just to show a vector? -- Best Regards, Luciana Lima Brito MSc. in Computer Science --MP_/aPblJcGTM6gUG83M5lrY34K Content-Type: text/x-patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=0001-Implement-basic-json-output-for-the-derivation-compa.patch >From dc74d1a8f8f5e7527cdb63b66e8e2b937e614f32 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 | 83 +++++++++++++++++++- 1 file changed, 80 insertions(+), 3 deletions(-) diff --git a/guix-data-service/web/compare/controller.scm b/guix-data-service/web/compare/controller.scm index a6aa198..ab5f9c4 100644 --- a/guix-data-service/web/compare/controller.scm +++ b/guix-data-service/web/compare/controller.scm @@ -588,9 +588,86 @@ '(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 (not (string? hash-alg)) + '() + `((hash-algorithm . ,hash-alg))) + ,@(if (not (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))))) + + (args (assq-ref data 'arguments)) + (base-args (list->vector (assq-ref args 'base))) + (target-args (list->vector (assq-ref args 'target)))) + (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 + . ((base . ,base-args) + (target . ,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_/aPblJcGTM6gUG83M5lrY34K--