From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:bcc0::]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id WDGEGmDZemCWHAEAgWs5BA (envelope-from ) for ; Sat, 17 Apr 2021 14:49:36 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id yKElFmDZemBEJQAA1q6Kng (envelope-from ) for ; Sat, 17 Apr 2021 12:49:36 +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 D9E8195ED for ; Sat, 17 Apr 2021 14:49:35 +0200 (CEST) Received: from localhost ([::1]:60044 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lXkOE-0006M0-VY for larch@yhetil.org; Sat, 17 Apr 2021 08:49:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51066) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lXkO1-0006Ls-LV for guix-devel@gnu.org; Sat, 17 Apr 2021 08:49:21 -0400 Received: from mout01.posteo.de ([185.67.36.65]:42533) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lXkNz-00020A-Bs for guix-devel@gnu.org; Sat, 17 Apr 2021 08:49:21 -0400 Received: from submission (posteo.de [89.146.220.130]) by mout01.posteo.de (Postfix) with ESMTPS id CBA37240029 for ; Sat, 17 Apr 2021 14:49:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1618663754; bh=o3lp76MaOJpBBYVOGgFqRy/jdiqEUELQXQUJBCwXGEM=; h=Date:From:To:Cc:Subject:From; b=indHr99b9kdQYFlrg6GlTte5vtog8qWPRU8RPNbXD6LlofqUGlUxjkKD4UfzMQmDE BvRYO56Mo5UovvLX9sfJXHVMBqXc1rATrfTjXICO6rJN7FuMsG+65DrMt7yFRdKH2S PiUImsjUPLnXmuCjzSngd9/zLzLaUaYf3KlGJacFcf4iVTlwF3og/dlL8Nq6QJeot6 HSpbk0mP67+W/CHuLNk1LKywIr0vIJdMBP6026MdS/Qz2zQisdu7pVScVNsWXja2pd 1t+gBR5NXKFwZzx4dr6MHliK3UHy+fA41jd2/fG3PcTG9FOxzBqpAfdy7GtWVc99kM X8zprTGWtzuLQ== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4FMtF03MF8z6tmT; Sat, 17 Apr 2021 14:49:05 +0200 (CEST) Date: Sat, 17 Apr 2021 12:48:57 +0000 From: Luciana Lima Brito To: Christopher Baines Subject: Re: Outreachy - Guix Data Service: implementing basic json output for derivation comparison page Message-ID: <20210417094857.14599c72@lubrito> In-Reply-To: <877dl1xq15.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> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="MP_/wFsF.IhPndf.imUQzbzjTzF" 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=1618663776; 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=59wzRoAJtk12EuTgMknryFb0/zFXJxXv5aw7TvZivCQ=; b=FfSU6iJhDlZJ9AZyVnVSay2yBId8VDgRlzUzFc11Ux/QgPE9T0R7PFvjevqlixkWe1ImJT JkA10OpyN6hHKx011KxNKqOUkfTpTfec8LBoigk3cFnPuaH8FOYlc5livZgLvSWQ7EsAVM MviJndY8kDFYPpEXDeGqjAGYupmDwHmA3N3UHudqCw8NWhL65tel/j6EaiubfkbLSQBgS0 XnzMZMmHBFVnCES2RJ5ZrvHOfMmJSTtSyOKSOYkOnuPjgXsVNTzcOahlMX8+v2VcMGtdaY 7Sqanj3iArW0gG4BNT4kMVhGP/QQpiSqh5aM75xAsYMEIUai0z6lRtJv1NHQZg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1618663776; a=rsa-sha256; cv=none; b=ZbeRlinCsfKfA4s3FkXiwpJcMQ/+xFWR9wBBFSdP0MAS3Vz9XcjaWLxGzRra2FTysg90LU rUc7UFZG91ahmbeiW2+hlSi2v1O2cWON8h+mTPTGldec3WRqoh/TSVjxZ/j219y43udxwm N+h27hnGKYxBcNm00Nxrf5FdgxLx2ezWTk6tcBgIZC4LG4kQcAwTQ972PbX0RsN+ptfTu6 1iEdYlsrzOuKsTtnfm5w0GG10pA68OtAiwzZe1wOmYk3lL8SL4OAkTC34qbDUZEH/JbUSC A7SEhDZ2DR9g/1wUDlR+MYJbabmK2lHdCF0Z5gI8OGVMrjkiFjoHj5ybqo7+tg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=indHr99b; 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=indHr99b; 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: D9E8195ED X-Spam-Score: -1.14 X-Migadu-Scanner: scn0.migadu.com X-TUID: DDhj243xzAac --MP_/wFsF.IhPndf.imUQzbzjTzF Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline On Sat, 17 Apr 2021 09:40:22 +0100 Christopher Baines wrote: > I think you're getting there, but it looks like you're close to what > you want with matched-outputs say, and then later you pick bits out > of that alist, generate vectors from the lists, and then rebuild the > alist. I think you can remove all that complexity by just tweaking > what you're doing up when you generate matched-outputs. I think this > is true for matched-outputs, matched-inputs and matched-sources. It's beautiful! Now I could understand better the alist, and things make much more sense to me. I simplified this part of getting properly the values from matched-outputs, matched-inputs and matched-sources. -- Best Regards, Luciana Lima Brito MSc. in Computer Science --MP_/wFsF.IhPndf.imUQzbzjTzF Content-Type: text/x-patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=0001-Implement-basic-json-output-for-the-derivation-compa.patch >From 8d91269ead953c7d087242fbce5857af89af3025 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 | 114 ++++++++++++++++++- 1 file changed, 111 insertions(+), 3 deletions(-) diff --git a/guix-data-service/web/compare/controller.scm b/guix-data-service/web/compare/controller.scm index a6aa198..d05c177 100644 --- a/guix-data-service/web/compare/controller.scm +++ b/guix-data-service/web/compare/controller.scm @@ -588,9 +588,117 @@ '(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 '())))) + '(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 + (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 + (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)))) + + (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 + . ((base . ,(list->vector (assq-ref matched-outputs 'base))) + (target . ,(list->vector (assq-ref matched-outputs 'target))) + (common . ,(list->vector (assq-ref matched-outputs 'common))))) + (inputs + . ((base . ,(list->vector (assq-ref matched-inputs 'base))) + (target . ,(list->vector (assq-ref matched-inputs 'target))))) + (sources + . ((base . ,(list->vector (assq-ref matched-sources 'base))) + (target . ,(list->vector (assq-ref matched-sources 'target))) + (common . ,(list->vector (assq-ref matched-sources 'common))))) + (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_/wFsF.IhPndf.imUQzbzjTzF--