aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2019-07-22 20:29:38 +0100
committerChristopher Baines <mail@cbaines.net>2019-07-22 20:29:38 +0100
commit219b1fd4ad60c1abf6f2b27b94410c176f4bf990 (patch)
tree3398f3deb26a3083ee6f97b9b3054c62fe05dbc0
parent7a70e9ca6fa666e7f92ebeda8e98ae2859ec97bf (diff)
downloaddata-service-219b1fd4ad60c1abf6f2b27b94410c176f4bf990.tar
data-service-219b1fd4ad60c1abf6f2b27b94410c176f4bf990.tar.gz
Extract out view-revision/jobs-and-events
This is common to both view-revision and unknown-revision.
-rw-r--r--guix-data-service/web/view/html.scm136
1 files changed, 48 insertions, 88 deletions
diff --git a/guix-data-service/web/view/html.scm b/guix-data-service/web/view/html.scm
index bf9c366..b503ce4 100644
--- a/guix-data-service/web/view/html.scm
+++ b/guix-data-service/web/view/html.scm
@@ -416,6 +416,52 @@
branches))))
git-repositories-and-branches)))
+(define (view-revision/jobs-and-events jobs-and-events)
+ `((h3 "Jobs")
+ (table
+ (@ (class "table"))
+ (thead
+ (tr
+ (th "Source")
+ (th "Events")
+ (th "")))
+ (tbody
+ ,@(map (match-lambda
+ ((id commit source git-repository-id created-at succeeded-at
+ events log-exists?)
+ `(tr
+ (@ (class
+ ,(let ((event-names
+ (map (lambda (event)
+ (assoc-ref event "event"))
+ (vector->list events))))
+ (cond
+ ((member "success" event-names)
+ "success")
+ ((member "failure" event-names)
+ "danger")
+ ((member "start" event-names)
+ "info")
+ (else
+ "")))))
+ (td ,source)
+ (td
+ (dl
+ ,@(map
+ (lambda (event)
+ `((dt ,(assoc-ref event "event"))
+ (dd ,(assoc-ref event "occurred_at"))))
+ (cons
+ `(("event" . "created")
+ ("occurred_at" . ,created-at))
+ (vector->list events)))))
+ (td
+ ,@(if log-exists?
+ `((a (@ (href ,(string-append "/job/" id)))
+ "View log"))
+ '())))))
+ jobs-and-events)))))
+
(define* (view-revision commit-hash packages-count
git-repositories-and-branches derivations-count
jobs-and-events
@@ -447,50 +493,7 @@
'()
(view-revision/git-repositories git-repositories-and-branches
commit-hash))
- (h3 "Jobs")
- (table
- (@ (class "table"))
- (thead
- (tr
- (th "Source")
- (th "Events")
- (th "")))
- (tbody
- ,@(map (match-lambda
- ((id commit source git-repository-id created-at succeeded-at
- events log-exists?)
- `(tr
- (@ (class
- ,(let ((event-names
- (map (lambda (event)
- (assoc-ref event "event"))
- (vector->list events))))
- (cond
- ((member "success" event-names)
- "success")
- ((member "failure" event-names)
- "danger")
- ((member "start" event-names)
- "info")
- (else
- "")))))
- (td ,source)
- (td
- (dl
- ,@(map
- (lambda (event)
- `((dt ,(assoc-ref event "event"))
- (dd ,(assoc-ref event "occurred_at"))))
- (cons
- `(("event" . "created")
- ("occurred_at" . ,created-at))
- (vector->list events)))))
- (td
- ,@(if log-exists?
- `((a (@ (href ,(string-append "/job/" id)))
- "View log"))
- '())))))
- jobs-and-events))))
+ ,@(view-revision/jobs-and-events jobs-and-events))
(div
(@ (class "col-md-6"))
(h3 "Derivations")
@@ -1573,50 +1576,7 @@
(view-revision/git-repositories
git-repositories-and-branches
commit-hash))
- (h3 "Jobs")
- (table
- (@ (class "table"))
- (thead
- (tr
- (th "Source")
- (th "Events")
- (th "")))
- (tbody
- ,@(map (match-lambda
- ((id commit source git-repository-id created-at succeeded-at
- events log-exists?)
- `(tr
- (@ (class
- ,(let ((event-names
- (map (lambda (event)
- (assoc-ref event "event"))
- (vector->list events))))
- (cond
- ((member "success" event-names)
- "success")
- ((member "failure" event-names)
- "danger")
- ((member "start" event-names)
- "info")
- (else
- "")))))
- (td ,source)
- (td
- (dl
- ,@(map
- (lambda (event)
- `((dt ,(assoc-ref event "event"))
- (dd ,(assoc-ref event "occurred_at"))))
- (cons
- `(("event" . "created")
- ("occurred_at" . ,created-at))
- (vector->list events)))))
- (td
- ,@(if log-exists?
- `((a (@ (href ,(string-append "/job/" id)))
- "View log"))
- '())))))
- jobs-and-events))))
+ ,@(view-revision/jobs-and-events jobs-and-events))
(div
(@ (class "col-md-6"))
(h3 "Derivations")