From f1454d0b99c070a0540d7d3b2bd02d4ca68dfe7a Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Sun, 15 Dec 2019 14:17:09 +0000 Subject: Move group-to-alist to the model utils module So it can be more widely used. --- guix-data-service/comparison.scm | 14 -------------- guix-data-service/model/utils.scm | 15 +++++++++++++++ 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 -- cgit v1.2.3