guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Outreachy - Guix Data Service: implementing basic json output for de


From: Christopher Baines
Subject: Re: Outreachy - Guix Data Service: implementing basic json output for derivation comparison page
Date: Mon, 19 Apr 2021 21:20:18 +0100
User-agent: mu4e 1.4.15; emacs 27.1

Luciana Lima Brito <lubrito@posteo.net> writes:

> On Mon, 19 Apr 2021 09:26:13 +0100
> Christopher Baines <mail@cbaines.net> 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.

Great, I've gone ahead and pushed this now.

I tweaked the following things, it's mostly removing trailing
whitespace, and I changed the way the alist was formatted, just so it's
a bit more compact (how it was before is OK as well).

@@ -617,7 +617,7 @@
                      (lambda (label items)
                        (cons label
                              (list->vector
-                              (map 
+                              (map
                                (match-lambda
                                  ((derivation output)
                                   `((derivation . ,derivation)
@@ -651,24 +651,18 @@
                        ((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)))
+                `((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



In terms of what to do next, you could continue on this derivation
comparison path. Some of the code you've got here could be used to make
the data better right when the database is queried. Take the recursive
field for outputs for example, it would be better to convert it to a
boolean where the database query is made.

Also, there's some admin to do in terms of recording a contribution, and
starting to think about submitting the final application.

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]