Add JSON representation for the Jobs page
Signed-off-by: Christopher Baines <mail@cbaines.net>
This commit is contained in:
parent
d09a1ca791
commit
60cb07f469
2 changed files with 42 additions and 8 deletions
|
|
@ -19,6 +19,7 @@
|
|||
#:use-module (ice-9 match)
|
||||
#:use-module (guix-data-service web render)
|
||||
#:use-module (guix-data-service web query-parameters)
|
||||
#:use-module (guix-data-service web util)
|
||||
#:use-module (guix-data-service jobs load-new-guix-revision)
|
||||
#:use-module (guix-data-service web jobs html)
|
||||
#:export (jobs-controller))
|
||||
|
|
@ -79,6 +80,30 @@
|
|||
(assq-ref query-parameters 'before_id)
|
||||
limit-results))
|
||||
(recent-events (select-recent-job-events conn)))
|
||||
(case (most-appropriate-mime-type
|
||||
'(application/json text/html)
|
||||
mime-types)
|
||||
((application/json)
|
||||
(render-json
|
||||
`((recent-events
|
||||
. ,(list->vector
|
||||
(map (match-lambda
|
||||
((_ commit _ _ event occurred_at)
|
||||
`((commit . ,commit)
|
||||
(event . ,event)
|
||||
(occurred_at . ,occurred_at))))
|
||||
recent-events)))
|
||||
(jobs
|
||||
. ,(list->vector
|
||||
(map (match-lambda
|
||||
((_ commit source _ created-at _ events log)
|
||||
`((commit . ,commit)
|
||||
(source . ,source)
|
||||
(created-at . ,created-at)
|
||||
(events . ,events)
|
||||
(log . ,log))))
|
||||
jobs))))))
|
||||
(else
|
||||
(render-html
|
||||
#:sxml (view-jobs
|
||||
query-parameters
|
||||
|
|
@ -86,7 +111,7 @@
|
|||
recent-events
|
||||
(and limit-results
|
||||
(>= (length jobs)
|
||||
limit-results))))))
|
||||
limit-results))))))))
|
||||
|
||||
(define (render-job-events mime-types conn query-parameters)
|
||||
(let* ((limit-results
|
||||
|
|
|
|||
|
|
@ -108,6 +108,15 @@
|
|||
(button (@ (type "submit")
|
||||
(class "btn btn-lg btn-primary"))
|
||||
"Update results")))))))
|
||||
(div
|
||||
(@ (class "btn-group pull-right")
|
||||
(role "group"))
|
||||
(a (@ (class "btn btn-lg btn-default")
|
||||
(href ,(string-append
|
||||
"/jobs.json"))
|
||||
(role "button"))
|
||||
"View JSON"))
|
||||
|
||||
(div
|
||||
(@ (class "row"))
|
||||
(div
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue