aboutsummaryrefslogtreecommitdiff
path: root/guix-data-service
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2020-02-11 08:56:24 +0000
committerChristopher Baines <mail@cbaines.net>2020-02-11 08:56:24 +0000
commit9be7dbac0b4ea7b9fabd6c3a66b3d1c95d43e657 (patch)
tree50d3d7f28b6939936c32a3fea852ba1c6b989e62 /guix-data-service
parent406aa5e160c14ebdc2d9a81d3e64c294a0438849 (diff)
downloaddata-service-9be7dbac0b4ea7b9fabd6c3a66b3d1c95d43e657.tar
data-service-9be7dbac0b4ea7b9fabd6c3a66b3d1c95d43e657.tar.gz
Start storing channel instance derivations
These are the ones that relate to Guix pull.
Diffstat (limited to 'guix-data-service')
-rw-r--r--guix-data-service/jobs/load-new-guix-revision.scm12
-rw-r--r--guix-data-service/model/channel-instance.scm52
2 files changed, 64 insertions, 0 deletions
diff --git a/guix-data-service/jobs/load-new-guix-revision.scm b/guix-data-service/jobs/load-new-guix-revision.scm
index efc2417..13668d8 100644
--- a/guix-data-service/jobs/load-new-guix-revision.scm
+++ b/guix-data-service/jobs/load-new-guix-revision.scm
@@ -35,6 +35,7 @@
#:use-module (guix-data-service config)
#:use-module (guix-data-service database)
#:use-module (guix-data-service model build)
+ #:use-module (guix-data-service model channel-instance)
#:use-module (guix-data-service model channel-news)
#:use-module (guix-data-service model package)
#:use-module (guix-data-service model package-derivation-by-guix-revision-range)
@@ -1206,6 +1207,17 @@ ORDER BY packages.name, packages.version"
guix-revision-id
(extract-information-from conn guix-revision-id
commit store-item)
+ (insert-channel-instances conn
+ guix-revision-id
+ (filter-map
+ (match-lambda
+ ((system . derivations)
+ (and=>
+ (assoc-ref derivations
+ 'manifest-entry-item)
+ (lambda (drv)
+ (cons system drv)))))
+ channel-derivations-by-system))
(if (defined? 'channel-news-for-commit
(resolve-module '(guix channels)))
(log-time
diff --git a/guix-data-service/model/channel-instance.scm b/guix-data-service/model/channel-instance.scm
new file mode 100644
index 0000000..9df2722
--- /dev/null
+++ b/guix-data-service/model/channel-instance.scm
@@ -0,0 +1,52 @@
+;;; Guix Data Service -- Information about Guix over time
+;;; Copyright © 2020 Christopher Baines <mail@cbaines.net>
+;;;
+;;; This program is free software: you can redistribute it and/or
+;;; modify it under the terms of the GNU Affero General Public License
+;;; as published by the Free Software Foundation, either version 3 of
+;;; the License, or (at your option) any later version.
+;;;
+;;; This program is distributed in the hope that it will be useful,
+;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;;; Affero General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU Affero General Public
+;;; License along with this program. If not, see
+;;; <http://www.gnu.org/licenses/>.
+
+(define-module (guix-data-service model channel-instance)
+ #:use-module (srfi srfi-1)
+ #:use-module (ice-9 match)
+ #:use-module (squee)
+ #:use-module (json)
+ #:use-module (guix utils)
+ #:use-module (guix-data-service model utils)
+ #:use-module (guix-data-service model derivation)
+ #:export (insert-channel-instances))
+
+(define (insert-channel-instances conn
+ guix-revision-id
+ derivations-by-system)
+ (let ((derivation-ids
+ (derivation-file-names->derivation-ids
+ conn
+ (map cdr derivations-by-system))))
+
+ (exec-query
+ conn
+ (string-append
+ "
+INSERT INTO channel_instances
+ (guix_revision_id, system, derivation_id)
+VALUES "
+ (string-join
+ (map (lambda (system derivation-id)
+ (simple-format #f "(~A, '~A', ~A)"
+ guix-revision-id
+ system
+ derivation-id))
+ (map car derivations-by-system)
+ derivation-ids)
+ ", "))))
+ #t)