From 2b5594e5d4861c1a5c40bb12e72124e714351f54 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Thu, 5 Sep 2019 13:51:42 +0200 Subject: Support deleting duplicates in insert-missing-data-and-return-all-ids This is useful when you want to pass in data with some duplicates, and get back a list of ids, where the duplicate entries are represented by the same id. --- guix-data-service/model/utils.scm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/guix-data-service/model/utils.scm b/guix-data-service/model/utils.scm index e636988..f569080 100644 --- a/guix-data-service/model/utils.scm +++ b/guix-data-service/model/utils.scm @@ -77,7 +77,8 @@ fields data #:key - sets-of-data?) + sets-of-data? + delete-duplicates?) (define field-strings (map symbol->string fields)) @@ -180,7 +181,9 @@ existing-entries))) (if sets-of-data? (delete-duplicates (concatenate data)) - data))) + (if delete-duplicates? + (delete-duplicates data) + data)))) (new-entries (if (null? missing-entries) '() -- cgit v1.2.3