diff options
Diffstat (limited to 'guix-data-service/model/system.scm')
-rw-r--r-- | guix-data-service/model/system.scm | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/guix-data-service/model/system.scm b/guix-data-service/model/system.scm index e64e7f5..9939a73 100644 --- a/guix-data-service/model/system.scm +++ b/guix-data-service/model/system.scm @@ -22,6 +22,7 @@ #:use-module (squee) #:use-module (guix-data-service model utils) #:export (system->system-id + lookup-system-id list-systems)) (define system->system-id-cache @@ -45,6 +46,22 @@ (set! systems-cache #f) id))))) +(define (lookup-system-id conn system) + (let ((cached-value (hash-ref system->system-id-cache + system))) + (or cached-value + (match (exec-query + conn + "SELECT id FROM systems WHERE system = $1" + (list system)) + (((id-string)) + (let ((id (string->number id-string))) + (hash-set! system->system-id-cache + system + id) + id)) + (() #f))))) + (define (list-systems conn) (if systems-cache systems-cache |