diff options
author | Christopher Baines <mail@cbaines.net> | 2024-01-18 14:41:54 +0000 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2024-01-18 14:41:54 +0000 |
commit | e51f87cc7ea0b38254a8b1a01c83c6b8f6173812 (patch) | |
tree | 3c28ef95fe72ed66c41368ddb67becc6feff2838 /guix-data-service | |
parent | b8bd56a8f5441bb45f0f3731987fda27ccd9674f (diff) | |
download | data-service-e51f87cc7ea0b38254a8b1a01c83c6b8f6173812.tar data-service-e51f87cc7ea0b38254a8b1a01c83c6b8f6173812.tar.gz |
Rewrite part of insert-missing-data-and-return-all-ids to avoid filter
As filter can use part of the input list, which then prevents modifying the
filtered list.
Diffstat (limited to 'guix-data-service')
-rw-r--r-- | guix-data-service/model/utils.scm | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/guix-data-service/model/utils.scm b/guix-data-service/model/utils.scm index b46e2e4..c05f20d 100644 --- a/guix-data-service/model/utils.scm +++ b/guix-data-service/model/utils.scm @@ -406,17 +406,24 @@ WHERE table_name = $1" data) 3000))))) (missing-entries - (filter (lambda (field-values) - (not (vhash-assoc - ;; Normalise at this point, so that the proper value - ;; to insert is carried forward - (normalise-values field-values) - existing-entries))) - (if sets-of-data? - (delete-duplicates* (concatenate data)) - (if delete-duplicates? - (delete-duplicates* data) - data)))) + (let loop ((lst (if sets-of-data? + (concatenate data) + data)) + (result '())) + (if (null? lst) + (if delete-duplicates? + (delete-duplicates* result) + result) + (let ((field-values (car lst))) + (if (vhash-assoc + ;; Normalise at this point, so that the proper value + ;; to insert is carried forward + (normalise-values field-values) + existing-entries) + (loop (cdr lst) + result) + (loop (cdr lst) + (cons field-values result))))))) (new-entries (if (null? missing-entries) '() |