aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2019-11-09 20:39:47 +0000
committerChristopher Baines <mail@cbaines.net>2019-11-09 20:39:47 +0000
commit7b3bc5bcfa1fd92e97712d54cce3c9c4f93da043 (patch)
tree4b6606c9f154f0a77ea03e9b361182754d7ddb97
parent4710d4e3983b48d41f56a9ac17b2ecf31af2a6dd (diff)
downloaddata-service-7b3bc5bcfa1fd92e97712d54cce3c9c4f93da043.tar
data-service-7b3bc5bcfa1fd92e97712d54cce3c9c4f93da043.tar.gz
Improve some derivation model functions
Return integer values for ids, rather than strings (as this type is more appropriate). Also, better parse the derivation arguments and environment variables.
-rw-r--r--guix-data-service/model/build.scm2
-rw-r--r--guix-data-service/model/derivation.scm20
2 files changed, 16 insertions, 6 deletions
diff --git a/guix-data-service/model/build.scm b/guix-data-service/model/build.scm
index bcfa444..74fe296 100644
--- a/guix-data-service/model/build.scm
+++ b/guix-data-service/model/build.scm
@@ -60,7 +60,7 @@
"WHERE builds.derivation_id = $1 "
"ORDER BY latest_build_status.status_fetched_at DESC "))
- (exec-query conn query (list derivation-id)))
+ (exec-query conn query (list (number->string derivation-id))))
(define (select-build-by-build-server-and-id
conn build-server-id id)
diff --git a/guix-data-service/model/derivation.scm b/guix-data-service/model/derivation.scm
index 9502ee6..4b79682 100644
--- a/guix-data-service/model/derivation.scm
+++ b/guix-data-service/model/derivation.scm
@@ -3,6 +3,7 @@
#:use-module (ice-9 vlist)
#:use-module (ice-9 match)
#:use-module (squee)
+ #:use-module (json)
#:use-module (guix base32)
#:use-module (guix inferior)
#:use-module (guix memoization)
@@ -202,15 +203,24 @@ ORDER BY derivations.system DESC,
(define (select-derivation-by-file-name conn file-name)
(define query
(string-append
- "SELECT id, file_name, builder, args, env_vars, system "
+ "SELECT id, file_name, builder, args, to_json(env_vars), system "
"FROM derivations "
"WHERE file_name = $1"))
(match (exec-query conn query (list file-name))
(()
#f)
- ((result)
- result)))
+ (((id file_name builder args env_vars system))
+ (list (string->number id)
+ file-name
+ builder
+ (parse-postgresql-array-string args)
+ (map (match-lambda
+ (#(key value)
+ `((key . ,key)
+ (value . ,value))))
+ (vector->list (json-string->scm env_vars)))
+ system))))
(define select-derivation-output-id
(mlambda (conn name path)
@@ -240,7 +250,7 @@ ORDER BY derivations.system DESC,
"derivation_outputs.derivation_output_details_id = derivation_output_details.id "
"WHERE derivation_id = $1"))
- (exec-query conn query (list id)))
+ (exec-query conn query (list (number->string id))))
(define (select-derivation-inputs-by-derivation-id conn id)
(define query
@@ -258,7 +268,7 @@ INNER JOIN derivations
WHERE derivation_inputs.derivation_id = $1
ORDER BY derivations.file_name"))
- (exec-query conn query (list id)))
+ (exec-query conn query (list (number->string id))))
(define (insert-derivation-inputs conn derivation-id derivation-inputs)
(define (insert-into-derivation-inputs output-ids)