[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
07/11: Improve select-job-for-commit
From: |
Christopher Baines |
Subject: |
07/11: Improve select-job-for-commit |
Date: |
Fri, 9 Oct 2020 15:21:20 -0400 (EDT) |
cbaines pushed a commit to branch master
in repository data-service.
commit 6023aa8caf6e7098109b756ca490ca73d0cbe559
Author: Christopher Baines <mail@cbaines.net>
AuthorDate: Fri Oct 9 19:31:51 2020 +0100
Improve select-job-for-commit
It now returns #f or a list, rather than the empty list or a nested list.
---
guix-data-service/jobs/load-new-guix-revision.scm | 4 +-
guix-data-service/web/compare/html.scm | 20 ++++----
guix-data-service/web/revision/html.scm | 61 +++++++++++------------
tests/jobs-load-new-guix-revision.scm | 2 +-
4 files changed, 44 insertions(+), 43 deletions(-)
diff --git a/guix-data-service/jobs/load-new-guix-revision.scm
b/guix-data-service/jobs/load-new-guix-revision.scm
index de9d4a8..691cda1 100644
--- a/guix-data-service/jobs/load-new-guix-revision.scm
+++ b/guix-data-service/jobs/load-new-guix-revision.scm
@@ -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))
diff --git a/guix-data-service/web/compare/html.scm
b/guix-data-service/web/compare/html.scm
index 684ca7e..8fdc80d 100644
--- a/guix-data-service/web/compare/html.scm
+++ b/guix-data-service/web/compare/html.scm
@@ -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)))
+ "."))
'())))))
diff --git a/guix-data-service/web/revision/html.scm
b/guix-data-service/web/revision/html.scm
index 32cd3ec..77a3e13 100644
--- a/guix-data-service/web/revision/html.scm
+++ b/guix-data-service/web/revision/html.scm
@@ -2147,36 +2147,35 @@ figure {
`(,(header)
(div
(@ (class "container"))
- ,@(match job
- (()
- `((h1 "Unknown revision")
- (p "No known revision with commit "
- (strong (samp ,commit-hash)))))
- ((jobs ...)
- `((div
- (@ (class "row"))
- (div
- (@ (class "col-md-12"))
- (h1 (@ (style "white-space: nowrap;"))
- "Revision " (samp ,commit-hash))))
- (div
- (@ (class "row"))
+ ,@(if job
+ `((div
+ (@ (class "row"))
+ (div
+ (@ (class "col-md-12"))
+ (h1 (@ (style "white-space: nowrap;"))
+ "Revision " (samp ,commit-hash))))
(div
- (@ (class "col-md-6"))
- (h2 "Packages")
- (strong (@ (class "text-center")
- (style "font-size: 2em; display: block;"))
- "Unknown")
+ (@ (class "row"))
+ (div
+ (@ (class "col-md-6"))
+ (h2 "Packages")
+ (strong (@ (class "text-center")
+ (style "font-size: 2em; display: block;"))
+ "Unknown")
+
+ ,@(if (null? git-repositories-and-branches)
+ '()
+ (view-revision/git-repositories
+ git-repositories-and-branches
+ commit-hash))
+ ,@(view-revision/jobs-and-events jobs-and-events))
+ (div
+ (@ (class "col-md-6"))
+ (h3 "Derivations")
+ (strong (@ (class "text-center")
+ (style "font-size: 2em; display: block;"))
+ "Unknown"))))
+ `((h1 "Unknown revision")
+ (p "No known revision with commit "
+ (strong (samp ,commit-hash)))))))))
- ,@(if (null? git-repositories-and-branches)
- '()
- (view-revision/git-repositories
- git-repositories-and-branches
- commit-hash))
- ,@(view-revision/jobs-and-events jobs-and-events))
- (div
- (@ (class "col-md-6"))
- (h3 "Derivations")
- (strong (@ (class "text-center")
- (style "font-size: 2em; display: block;"))
- "Unknown"))))))))))
diff --git a/tests/jobs-load-new-guix-revision.scm
b/tests/jobs-load-new-guix-revision.scm
index 99acfa7..7d722af 100644
--- a/tests/jobs-load-new-guix-revision.scm
+++ b/tests/jobs-load-new-guix-revision.scm
@@ -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")
- branch master updated (f1eb2d3 -> 4f3be14), Christopher Baines, 2020/10/09
- 01/11: Guard against derivation IDs that aren't numbers, Christopher Baines, 2020/10/09
- 02/11: Guard against errors when recording job stderr output, Christopher Baines, 2020/10/09
- 04/11: Change the derivation comparison targets, Christopher Baines, 2020/10/09
- 03/11: Link to the revisions in the comparison header, Christopher Baines, 2020/10/09
- 05/11: Use letpar& for systems and targets in render-compare/derivations, Christopher Baines, 2020/10/09
- 06/11: Clarify that the derivations comparison only is for packages, Christopher Baines, 2020/10/09
- 08/11: Include tablespace as a label for table metrics, Christopher Baines, 2020/10/09
- 09/11: Include the base commit and target commit in the compare output, Christopher Baines, 2020/10/09
- 07/11: Improve select-job-for-commit,
Christopher Baines <=
- 10/11: Add Prometheus metrics for indexes specifically, Christopher Baines, 2020/10/09
- 11/11: Split the jobs metric in to succeede, queued and failed, Christopher Baines, 2020/10/09