Add a JSON variant of the revision page
This commit is contained in:
parent
bd8b9f951c
commit
b3f2aab8c9
1 changed files with 30 additions and 7 deletions
|
|
@ -78,6 +78,33 @@
|
||||||
target-commit
|
target-commit
|
||||||
(commit->revision-id conn target-commit))))
|
(commit->revision-id conn target-commit))))
|
||||||
|
|
||||||
|
(define (render-view-revision mime-types
|
||||||
|
conn
|
||||||
|
commit-hash)
|
||||||
|
(let ((packages-count
|
||||||
|
(count-packages-in-revision conn commit-hash))
|
||||||
|
(derivations-counts
|
||||||
|
(count-packages-derivations-in-revision conn commit-hash)))
|
||||||
|
(case (most-appropriate-mime-type
|
||||||
|
'(application/json text/html)
|
||||||
|
mime-types)
|
||||||
|
((application/json)
|
||||||
|
(render-json
|
||||||
|
`((packages_count . ,(caar packages-count))
|
||||||
|
(derivations_counts . ,(list->vector
|
||||||
|
(map (match-lambda
|
||||||
|
((system target derivation_count)
|
||||||
|
`((system . ,system)
|
||||||
|
(target . ,target)
|
||||||
|
(derivation_count . ,derivation_count))))
|
||||||
|
derivations-counts))))))
|
||||||
|
(else
|
||||||
|
(apply render-html
|
||||||
|
(view-revision
|
||||||
|
commit-hash
|
||||||
|
packages-count
|
||||||
|
derivations-counts))))))
|
||||||
|
|
||||||
(define (render-compare-unknown-commit mime-types
|
(define (render-compare-unknown-commit mime-types
|
||||||
conn
|
conn
|
||||||
base-commit
|
base-commit
|
||||||
|
|
@ -347,13 +374,9 @@
|
||||||
(apply render-html
|
(apply render-html
|
||||||
(view-statistics (count-guix-revisions conn)
|
(view-statistics (count-guix-revisions conn)
|
||||||
(count-derivations conn))))
|
(count-derivations conn))))
|
||||||
((GET "revision" commit-hash)
|
((GET "revision" commit-hash) (render-view-revision mime-types
|
||||||
(apply render-html
|
conn
|
||||||
(view-revision commit-hash
|
commit-hash))
|
||||||
(count-packages-in-revision conn
|
|
||||||
commit-hash)
|
|
||||||
(count-packages-derivations-in-revision conn
|
|
||||||
commit-hash))))
|
|
||||||
((GET "revision" commit-hash "packages")
|
((GET "revision" commit-hash "packages")
|
||||||
(apply render-html
|
(apply render-html
|
||||||
(view-revision-packages commit-hash
|
(view-revision-packages commit-hash
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue