aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2019-12-15 14:17:09 +0000
committerChristopher Baines <mail@cbaines.net>2019-12-15 14:17:21 +0000
commitf1454d0b99c070a0540d7d3b2bd02d4ca68dfe7a (patch)
tree91250cf75d6521afabeefe6c409128744edcf0c8
parentf0c5aba95ec3e1a32b9d88f6e2763da53a234a19 (diff)
downloaddata-service-f1454d0b99c070a0540d7d3b2bd02d4ca68dfe7a.tar
data-service-f1454d0b99c070a0540d7d3b2bd02d4ca68dfe7a.tar.gz
Move group-to-alist to the model utils module
So it can be more widely used.
-rw-r--r--guix-data-service/comparison.scm14
-rw-r--r--guix-data-service/model/utils.scm15
2 files changed, 15 insertions, 14 deletions
diff --git a/guix-data-service/comparison.scm b/guix-data-service/comparison.scm
index d1d9630..59f617f 100644
--- a/guix-data-service/comparison.scm
+++ b/guix-data-service/comparison.scm
@@ -24,20 +24,6 @@
channel-news-differences-data))
-(define (group-to-alist process lst)
- (fold (lambda (element result)
- (match (process element)
- ((key . value)
- (match (assoc key result)
- ((_ . existing-values)
- `((,key . ,(cons value existing-values))
- ,@result))
- (#f
- `((,key . (,value))
- ,@result))))))
- '()
- lst))
-
(define (derivation-differences-data conn
base-derivation-file-name
target-derivation-file-name)
diff --git a/guix-data-service/model/utils.scm b/guix-data-service/model/utils.scm
index c17224b..af60e45 100644
--- a/guix-data-service/model/utils.scm
+++ b/guix-data-service/model/utils.scm
@@ -14,6 +14,7 @@
parse-postgresql-array-string
deduplicate-strings
group-list-by-first-n-fields
+ group-to-alist
insert-missing-data-and-return-all-ids))
(define NULL '())
@@ -81,6 +82,20 @@
'()
lists))
+(define (group-to-alist process lst)
+ (fold (lambda (element result)
+ (match (process element)
+ ((key . value)
+ (match (assoc key result)
+ ((_ . existing-values)
+ `((,key . ,(cons value existing-values))
+ ,@result))
+ (#f
+ `((,key . (,value))
+ ,@result))))))
+ '()
+ lst))
+
(define* (insert-missing-data-and-return-all-ids
conn
table-name