diff options
author | Christopher Baines <mail@cbaines.net> | 2019-09-04 19:28:48 +0200 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2019-09-05 16:07:23 +0200 |
commit | 1a55022524043bdf2f120dd38990d42949ecb6e2 (patch) | |
tree | be78a6ade65501dfa4563214f7fb60766eaea746 /guix-data-service | |
parent | f29230e034bd9d7ae201901efee18a166c966ea5 (diff) | |
download | data-service-1a55022524043bdf2f120dd38990d42949ecb6e2.tar data-service-1a55022524043bdf2f120dd38990d42949ecb6e2.tar.gz |
Improve the package and package-metadata modules
Add tests around the package module, extract out the use of the
inferior-package record assessors so that they aren't part of the tests, and
switch across the package-metadata module to use
insert-missing-data-and-return-all-ids.
Diffstat (limited to 'guix-data-service')
-rw-r--r-- | guix-data-service/jobs/load-new-guix-revision.scm | 9 | ||||
-rw-r--r-- | guix-data-service/model/package-metadata.scm | 43 | ||||
-rw-r--r-- | guix-data-service/model/package.scm | 11 |
3 files changed, 13 insertions, 50 deletions
diff --git a/guix-data-service/jobs/load-new-guix-revision.scm b/guix-data-service/jobs/load-new-guix-revision.scm index 75eae4d..64e955b 100644 --- a/guix-data-service/jobs/load-new-guix-revision.scm +++ b/guix-data-service/jobs/load-new-guix-revision.scm @@ -454,7 +454,10 @@ WHERE job_id = $1" (log-time "getting package-ids" (lambda () (inferior-packages->package-ids - conn packages packages-metadata-ids))))) + conn + (zip (map inferior-package-name packages) + (map inferior-package-version packages) + packages-metadata-ids)))))) (define (insert-lint-warnings conn inferior-package-id->package-database-id lint-checker-ids @@ -883,7 +886,9 @@ RETURNING id;") (match (exec-query conn query - (list git-repository-id commit source)) + (list (number->string git-repository-id) + commit + source)) ((result) result) (() #f))) diff --git a/guix-data-service/model/package-metadata.scm b/guix-data-service/model/package-metadata.scm index 178d783..daca676 100644 --- a/guix-data-service/model/package-metadata.scm +++ b/guix-data-service/model/package-metadata.scm @@ -144,42 +144,9 @@ WHERE packages.id IN ( packages license-set-ids)) - (let* ((existing-package-metadata-entries - (exec-query->vhash conn - (select-package-metadata package-metadata) - (match-lambda - ((id synopsis description home-page - location-id license-set-id) - (list synopsis - description - (non-empty-string-or-false home-page) - location-id - license-set-id))) - first)) ;; id)) - (missing-package-metadata-entries - (delete-duplicates - (filter (lambda (metadata) - (not (vhash-assoc metadata - existing-package-metadata-entries))) - package-metadata))) - (new-package-metadata-entries - (if (null? missing-package-metadata-entries) - '() - (map first - (exec-query conn - (insert-package-metadata - missing-package-metadata-entries))))) - (new-entries-id-lookup-vhash - (two-lists->vhash missing-package-metadata-entries - new-package-metadata-entries))) + (insert-missing-data-and-return-all-ids + conn + "package_metadata" + '(synopsis description home_page location_id license_set_id) + package-metadata)) - (map (lambda (package-metadata-values) - (cdr - (or (vhash-assoc package-metadata-values - existing-package-metadata-entries) - (vhash-assoc package-metadata-values - new-entries-id-lookup-vhash) - (begin - (error "missing package-metadata entry" - package-metadata-values))))) - package-metadata))) diff --git a/guix-data-service/model/package.scm b/guix-data-service/model/package.scm index 477a25c..49ebab0 100644 --- a/guix-data-service/model/package.scm +++ b/guix-data-service/model/package.scm @@ -9,7 +9,6 @@ select-packages-in-revision search-packages-in-revision count-packages-in-revision - insert-into-package-entries inferior-packages->package-ids)) (define (select-existing-package-entries package-entries) @@ -160,15 +159,7 @@ WHERE packages.id IN ( " RETURNING id" ";")) -(define (inferior-packages->package-ids conn packages metadata-ids) - (define package-entries - (map (lambda (package metadata-id) - (list (inferior-package-name package) - (inferior-package-version package) - metadata-id)) - packages - metadata-ids)) - +(define (inferior-packages->package-ids conn package-entries) (insert-missing-data-and-return-all-ids conn "packages" |