Improve select-job-for-commit

It now returns #f or a list, rather than the empty list or a nested list.
This commit is contained in:
Christopher Baines 2020-10-09 19:31:51 +01:00
parent 51204aefca
commit 6023aa8caf
4 changed files with 44 additions and 43 deletions

View file

@ -1388,7 +1388,9 @@ GROUP BY 1, 2")
"SELECT id, commit, source, git_repository_id "
"FROM load_new_guix_revision_jobs WHERE commit = $1")
(list commit))))
result))
(match result
(() #f)
((job) job))))
(define* (select-recent-job-events conn
#:key (limit 8))

View file

@ -1034,26 +1034,26 @@
(div (@ (class "container"))
(h1 "Unknown commit")
,(if (invalid-query-parameter? base-commit)
(if (null? base-job)
`(p "No known revision with commit "
(strong (samp ,(invalid-query-parameter-value base-commit)))
".")
(if base-job
`(p "Revision "
(a (@ (href
,(string-append "/revision/"
(invalid-query-parameter-value base-commit))))
(strong (samp ,(invalid-query-parameter-value base-commit))))
" is queued for processing."))
" is queued for processing.")
`(p "No known revision with commit "
(strong (samp ,(invalid-query-parameter-value base-commit)))
"."))
'())
,(if (invalid-query-parameter? target-commit)
(if (null? target-job)
`(p "No known revision with commit "
(strong (samp ,(invalid-query-parameter-value target-commit)))
".")
(if target-job
`(p "Revision "
(a (@ (href
,(string-append "/revision/"
(invalid-query-parameter-value target-commit))))
(strong (samp ,(invalid-query-parameter-value target-commit))))
" is queued for processing."))
" is queued for processing.")
`(p "No known revision with commit "
(strong (samp ,(invalid-query-parameter-value target-commit)))
"."))
'())))))

View file

@ -2147,12 +2147,7 @@ figure {
`(,(header)
(div
(@ (class "container"))
,@(match job
(()
`((h1 "Unknown revision")
(p "No known revision with commit "
(strong (samp ,commit-hash)))))
((jobs ...)
,@(if job
`((div
(@ (class "row"))
(div
@ -2179,4 +2174,8 @@ figure {
(h3 "Derivations")
(strong (@ (class "text-center")
(style "font-size: 2em; display: block;"))
"Unknown"))))))))))
"Unknown"))))
`((h1 "Unknown revision")
(p "No known revision with commit "
(strong (samp ,commit-hash)))))))))

View file

@ -21,7 +21,7 @@
(exec-query conn "TRUNCATE guix_revisions CASCADE")
(test-equal "select-job-for-commit works"
'()
#f
(select-job-for-commit conn "does not exist"))
(exec-query conn "TRUNCATE guix_revisions CASCADE")