aboutsummaryrefslogtreecommitdiff
path: root/guix-data-service/jobs
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2019-07-22 20:00:11 +0100
committerChristopher Baines <mail@cbaines.net>2019-07-22 20:00:11 +0100
commit91be72df039b1b1c914bece96a81d4b0cdee2144 (patch)
tree88252338dba6aeaffe67172c92af0d506999127a /guix-data-service/jobs
parent1f1deac29609fb63abf0f0a9939157df23b651a3 (diff)
downloaddata-service-91be72df039b1b1c914bece96a81d4b0cdee2144.tar
data-service-91be72df039b1b1c914bece96a81d4b0cdee2144.tar.gz
Display the jobs related to a revision on the revision page
Diffstat (limited to 'guix-data-service/jobs')
-rw-r--r--guix-data-service/jobs/load-new-guix-revision.scm35
1 files changed, 35 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 d1a5fb7..a24e24a 100644
--- a/guix-data-service/jobs/load-new-guix-revision.scm
+++ b/guix-data-service/jobs/load-new-guix-revision.scm
@@ -30,6 +30,7 @@
process-load-new-guix-revision-job
select-job-for-commit
select-jobs-and-events
+ select-jobs-and-events-for-commit
record-job-event
enqueue-load-new-guix-revision-job
most-recent-n-load-new-guix-revision-jobs))
@@ -676,6 +677,40 @@ ORDER BY load_new_guix_revision_jobs.id DESC")
(string=? log-exists? "t"))))
(exec-query conn query)))
+(define (select-jobs-and-events-for-commit conn commit)
+ (define query
+ "
+SELECT
+ load_new_guix_revision_jobs.id,
+ load_new_guix_revision_jobs.source,
+ load_new_guix_revision_jobs.git_repository_id,
+ load_new_guix_revision_jobs.created_at,
+ load_new_guix_revision_jobs.succeeded_at,
+ (
+ SELECT JSON_AGG(
+ json_build_object('event', event, 'occurred_at', occurred_at) ORDER BY occurred_at ASC
+ )
+ FROM load_new_guix_revision_job_events
+ WHERE job_id = load_new_guix_revision_jobs.id
+ ),
+ EXISTS (
+ SELECT 1 FROM load_new_guix_revision_job_logs WHERE job_id = load_new_guix_revision_jobs.id
+ ) AS log_exists
+FROM load_new_guix_revision_jobs
+WHERE commit = $1
+ORDER BY load_new_guix_revision_jobs.id DESC")
+
+ (map
+ (match-lambda
+ ((id source git-repository-id created-at succeeded-at
+ events-json log-exists?)
+ (list id commit source git-repository-id created-at succeeded-at
+ (if (string-null? events-json)
+ #()
+ (json-string->scm events-json))
+ (string=? log-exists? "t"))))
+ (exec-query conn query (list commit))))
+
(define (most-recent-n-load-new-guix-revision-jobs conn n)
(let ((result
(exec-query