Switch the compare/packages page to use parse-query-parameters
This commit is contained in:
parent
c9c7666b49
commit
30051a3740
2 changed files with 62 additions and 50 deletions
|
|
@ -613,10 +613,7 @@
|
||||||
|
|
||||||
(define (render-compare/packages mime-types
|
(define (render-compare/packages mime-types
|
||||||
conn
|
conn
|
||||||
base-commit
|
query-parameters)
|
||||||
base-revision-id
|
|
||||||
target-commit
|
|
||||||
target-revision-id)
|
|
||||||
(define (package-data-vhash->json vh)
|
(define (package-data-vhash->json vh)
|
||||||
(delete-duplicates
|
(delete-duplicates
|
||||||
(vhash-fold (lambda (name data result)
|
(vhash-fold (lambda (name data result)
|
||||||
|
|
@ -626,34 +623,52 @@
|
||||||
'()
|
'()
|
||||||
vh)))
|
vh)))
|
||||||
|
|
||||||
(let-values
|
(if (any-invalid-query-parameters? query-parameters)
|
||||||
(((base-packages-vhash target-packages-vhash)
|
(case (most-appropriate-mime-type
|
||||||
(package-data->package-data-vhashes
|
'(application/json text/html)
|
||||||
(package-differences-data conn
|
mime-types)
|
||||||
base-revision-id
|
((application/json)
|
||||||
target-revision-id))))
|
(render-json
|
||||||
(case (most-appropriate-mime-type
|
'((error . "invalid query"))))
|
||||||
'(application/json text/html)
|
(else
|
||||||
mime-types)
|
(render-html
|
||||||
((application/json)
|
#:sxml (compare/packages
|
||||||
(render-json
|
query-parameters
|
||||||
`((base
|
#f
|
||||||
. ((commit . ,base-commit)
|
#f))))
|
||||||
(packages . ,(list->vector
|
|
||||||
(package-data-vhash->json base-packages-vhash)))))
|
(let ((base-commit (assq-ref query-parameters 'base_commit))
|
||||||
(target
|
(target-commit (assq-ref query-parameters 'target_commit)))
|
||||||
. ((commit . ,target-commit)
|
(let ((base-revision-id (commit->revision-id conn base-commit))
|
||||||
(packages . ,(list->vector
|
(target-revision-id (commit->revision-id conn target-commit)))
|
||||||
(package-data-vhash->json target-packages-vhash))))))
|
|
||||||
#:extra-headers http-headers-for-unchanging-content))
|
(let-values
|
||||||
(else
|
(((base-packages-vhash target-packages-vhash)
|
||||||
(render-html
|
(package-data->package-data-vhashes
|
||||||
#:sxml (compare/packages
|
(package-differences-data conn
|
||||||
base-commit
|
base-revision-id
|
||||||
target-commit
|
target-revision-id))))
|
||||||
base-packages-vhash
|
(case (most-appropriate-mime-type
|
||||||
target-packages-vhash)
|
'(application/json text/html)
|
||||||
#:extra-headers http-headers-for-unchanging-content)))))
|
mime-types)
|
||||||
|
((application/json)
|
||||||
|
(render-json
|
||||||
|
`((base
|
||||||
|
. ((commit . ,base-commit)
|
||||||
|
(packages . ,(list->vector
|
||||||
|
(package-data-vhash->json base-packages-vhash)))))
|
||||||
|
(target
|
||||||
|
. ((commit . ,target-commit)
|
||||||
|
(packages . ,(list->vector
|
||||||
|
(package-data-vhash->json target-packages-vhash))))))
|
||||||
|
#:extra-headers http-headers-for-unchanging-content))
|
||||||
|
(else
|
||||||
|
(render-html
|
||||||
|
#:sxml (compare/packages
|
||||||
|
query-parameters
|
||||||
|
base-packages-vhash
|
||||||
|
target-packages-vhash)
|
||||||
|
#:extra-headers http-headers-for-unchanging-content))))))))
|
||||||
|
|
||||||
(define (render-derivation conn derivation-file-name)
|
(define (render-derivation conn derivation-file-name)
|
||||||
(let ((derivation (select-derivation-by-file-name conn
|
(let ((derivation (select-derivation-by-file-name conn
|
||||||
|
|
@ -1105,22 +1120,14 @@
|
||||||
conn
|
conn
|
||||||
parsed-query-parameters)))
|
parsed-query-parameters)))
|
||||||
(('GET "compare" "packages")
|
(('GET "compare" "packages")
|
||||||
(with-base-and-target-commits
|
(let* ((parsed-query-parameters
|
||||||
query-parameters conn
|
(parse-query-parameters
|
||||||
(lambda (base-commit base-revision-id target-commit target-revision-id)
|
request
|
||||||
(if (not (and base-revision-id target-revision-id))
|
`((base_commit ,(parse-commit conn) #:required)
|
||||||
(render-compare-unknown-commit mime-types
|
(target_commit ,(parse-commit conn) #:required)))))
|
||||||
conn
|
(render-compare/packages mime-types
|
||||||
base-commit
|
conn
|
||||||
base-revision-id
|
parsed-query-parameters)))
|
||||||
target-commit
|
|
||||||
target-revision-id)
|
|
||||||
(render-compare/packages mime-types
|
|
||||||
conn
|
|
||||||
base-commit
|
|
||||||
base-revision-id
|
|
||||||
target-commit
|
|
||||||
target-revision-id)))))
|
|
||||||
(('GET "jobs")
|
(('GET "jobs")
|
||||||
(render-jobs mime-types
|
(render-jobs mime-types
|
||||||
conn))
|
conn))
|
||||||
|
|
|
||||||
|
|
@ -1972,10 +1972,15 @@
|
||||||
(cdr data-columns))))))
|
(cdr data-columns))))))
|
||||||
(vector->list derivation-changes)))))))))))
|
(vector->list derivation-changes)))))))))))
|
||||||
|
|
||||||
(define (compare/packages base-commit
|
(define (compare/packages query-parameters
|
||||||
target-commit
|
|
||||||
base-packages-vhash
|
base-packages-vhash
|
||||||
target-packages-vhash)
|
target-packages-vhash)
|
||||||
|
(define base-commit
|
||||||
|
(assq-ref query-parameters 'base_commit))
|
||||||
|
|
||||||
|
(define target-commit
|
||||||
|
(assq-ref query-parameters 'target_commit))
|
||||||
|
|
||||||
(define query-params
|
(define query-params
|
||||||
(string-append "?base_commit=" base-commit
|
(string-append "?base_commit=" base-commit
|
||||||
"&target_commit=" target-commit))
|
"&target_commit=" target-commit))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue