summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2019-03-24 10:49:49 +0000
committerChristopher Baines <mail@cbaines.net>2019-03-24 10:49:49 +0000
commit21b07b07a973adcf94046f5bec2338c1207c35f4 (patch)
treea5b9bba052c63f1dae2c063162f8c87f090bea04
parent101caddecc552dd8ffc6ef4195390e674a9806cc (diff)
downloaddata-service-21b07b07a973adcf94046f5bec2338c1207c35f4.tar
data-service-21b07b07a973adcf94046f5bec2338c1207c35f4.tar.gz
Extract out deduplicate-strings to the utils module
-rw-r--r--guix-data-service/model/derivation.scm13
-rw-r--r--guix-data-service/model/utils.scm16
2 files changed, 15 insertions, 14 deletions
diff --git a/guix-data-service/model/derivation.scm b/guix-data-service/model/derivation.scm
index 7a710de..07b8ee6 100644
--- a/guix-data-service/model/derivation.scm
+++ b/guix-data-service/model/derivation.scm
@@ -519,19 +519,6 @@ ORDER BY derivations.system DESC,
(exec-query conn query))
-(define (deduplicate-strings strings)
- (pair-fold
- (lambda (pair result)
- (if (null? (cdr pair))
- (cons (first pair) result)
- (if (string=? (first pair) (second pair))
- result
- (cons (first pair) result))))
- '()
- (sort strings
- (lambda (a b)
- (string<? a b)))))
-
(define (deduplicate-derivations derivations)
(define sorted-derivations
(sort derivations
diff --git a/guix-data-service/model/utils.scm b/guix-data-service/model/utils.scm
index 8a85e2b..eab3b98 100644
--- a/guix-data-service/model/utils.scm
+++ b/guix-data-service/model/utils.scm
@@ -5,7 +5,8 @@
#:export (quote-string
value->quoted-string-or-null
exec-query->vhash
- two-lists->vhash))
+ two-lists->vhash
+ deduplicate-strings))
(define (quote-string s)
(string-append "'" s "'"))
@@ -29,3 +30,16 @@
vlist-null
l1
l2))
+
+(define (deduplicate-strings strings)
+ (pair-fold
+ (lambda (pair result)
+ (if (null? (cdr pair))
+ (cons (first pair) result)
+ (if (string=? (first pair) (second pair))
+ result
+ (cons (first pair) result))))
+ '()
+ (sort strings
+ (lambda (a b)
+ (string<? a b)))))