Move group-to-alist to the model utils module

So it can be more widely used.
This commit is contained in:
Christopher Baines 2019-12-15 14:17:09 +00:00
parent 18504fba49
commit a41249d8fe
2 changed files with 15 additions and 14 deletions

View file

@ -24,20 +24,6 @@
channel-news-differences-data)) 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 (define (derivation-differences-data conn
base-derivation-file-name base-derivation-file-name
target-derivation-file-name) target-derivation-file-name)

View file

@ -14,6 +14,7 @@
parse-postgresql-array-string parse-postgresql-array-string
deduplicate-strings deduplicate-strings
group-list-by-first-n-fields group-list-by-first-n-fields
group-to-alist
insert-missing-data-and-return-all-ids)) insert-missing-data-and-return-all-ids))
(define NULL '()) (define NULL '())
@ -81,6 +82,20 @@
'() '()
lists)) 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 (define* (insert-missing-data-and-return-all-ids
conn conn
table-name table-name