aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2019-10-13 19:46:04 +0100
committerChristopher Baines <mail@cbaines.net>2019-10-13 19:46:04 +0100
commitfc6aeab4edd0cf989fb10ee3818dac2a5f986b9b (patch)
tree36d68b18ccbabf41b147c18c983978bbd98d8b6e
parent9fa2e9e5ac92af3488bfee8b5573a3e3c522243c (diff)
downloaddata-service-fc6aeab4edd0cf989fb10ee3818dac2a5f986b9b.tar
data-service-fc6aeab4edd0cf989fb10ee3818dac2a5f986b9b.tar.gz
Add select-guix-revision-for-branch-and-datetime
To get the guix revision that was on a branch at a given date and time.
-rw-r--r--guix-data-service/model/guix-revision.scm21
1 files changed, 21 insertions, 0 deletions
diff --git a/guix-data-service/model/guix-revision.scm b/guix-data-service/model/guix-revision.scm
index 03253d3..8221ab4 100644
--- a/guix-data-service/model/guix-revision.scm
+++ b/guix-data-service/model/guix-revision.scm
@@ -1,5 +1,6 @@
(define-module (guix-data-service model guix-revision)
#:use-module (srfi srfi-1)
+ #:use-module (srfi srfi-19)
#:use-module (ice-9 match)
#:use-module (squee)
#:export (count-guix-revisions
@@ -8,6 +9,7 @@
insert-guix-revision
guix-commit-exists?
guix-revision-exists?
+ select-guix-revision-for-branch-and-datetime
guix-revisions-cgit-url-bases))
(define (count-guix-revisions conn)
@@ -59,6 +61,25 @@
(exec-query conn query))))
(string=? result "t")))
+(define (select-guix-revision-for-branch-and-datetime conn branch datetime)
+ (define query
+ "
+SELECT guix_revisions.id,
+ guix_revisions.commit,
+ guix_revisions.store_path,
+ guix_revisions.git_repository_id
+FROM guix_revisions
+INNER JOIN git_branches
+ ON git_branches.commit = guix_revisions.commit
+ AND git_branches.git_repository_id = guix_revisions.git_repository_id
+WHERE git_branches.name = $1 AND git_branches.datetime >= $2
+ORDER BY git_branches.datetime ASC
+LIMIT 1")
+
+ (car
+ (exec-query conn query (list branch
+ (date->string datetime "~1 ~3")))))
+
(define (guix-revisions-cgit-url-bases conn guix-revision-ids)
(map
car