Stream the /compare.json response
Since this could be quite large.
This commit is contained in:
parent
62cf3ff7cb
commit
a5e9e2f6a5
1 changed files with 123 additions and 84 deletions
|
|
@ -26,6 +26,8 @@
|
||||||
#:use-module (texinfo html)
|
#:use-module (texinfo html)
|
||||||
#:use-module (texinfo plain-text)
|
#:use-module (texinfo plain-text)
|
||||||
#:use-module (json)
|
#:use-module (json)
|
||||||
|
#:use-module (fibers)
|
||||||
|
#:use-module (knots promise)
|
||||||
#:use-module (knots parallelism)
|
#:use-module (knots parallelism)
|
||||||
#:use-module (knots resource-pool)
|
#:use-module (knots resource-pool)
|
||||||
#:use-module (guix-data-service utils)
|
#:use-module (guix-data-service utils)
|
||||||
|
|
@ -307,97 +309,134 @@
|
||||||
(version-changes
|
(version-changes
|
||||||
(package-data-version-changes base-packages-vhash
|
(package-data-version-changes base-packages-vhash
|
||||||
target-packages-vhash)))
|
target-packages-vhash)))
|
||||||
(fibers-let ((lint-warnings-data
|
(let ((lint-warnings-data-promise
|
||||||
(with-resource-from-pool (connection-pool) conn
|
(fibers-delay
|
||||||
(group-list-by-first-n-fields
|
(lambda ()
|
||||||
2
|
(with-resource-from-pool (connection-pool) conn
|
||||||
(lint-warning-differences-data conn
|
(group-list-by-first-n-fields
|
||||||
base-revision-id
|
2
|
||||||
target-revision-id
|
(lint-warning-differences-data conn
|
||||||
locale))))
|
|
||||||
(channel-news-data
|
|
||||||
(with-resource-from-pool (connection-pool) conn
|
|
||||||
(channel-news-differences-data conn
|
|
||||||
base-revision-id
|
base-revision-id
|
||||||
target-revision-id))))
|
target-revision-id
|
||||||
|
locale))))))
|
||||||
|
(channel-news-data-promise
|
||||||
|
(fibers-delay
|
||||||
|
(lambda ()
|
||||||
|
(with-resource-from-pool (connection-pool) conn
|
||||||
|
(channel-news-differences-data conn
|
||||||
|
base-revision-id
|
||||||
|
target-revision-id))))))
|
||||||
|
;; TODO Make this neater
|
||||||
|
(spawn-fiber
|
||||||
|
(lambda ()
|
||||||
|
(fibers-force lint-warnings-data-promise))
|
||||||
|
#:parallel? #t)
|
||||||
|
(spawn-fiber
|
||||||
|
(lambda ()
|
||||||
|
(fibers-force channel-news-data-promise))
|
||||||
|
#:parallel? #t)
|
||||||
|
|
||||||
(case (most-appropriate-mime-type
|
(case (most-appropriate-mime-type
|
||||||
'(application/json text/html)
|
'(application/json text/html)
|
||||||
mime-types)
|
mime-types)
|
||||||
((application/json)
|
((application/json)
|
||||||
(render-json
|
(render-json
|
||||||
`((base-commit . ,(assq-ref query-parameters 'base_commit))
|
(lambda (port)
|
||||||
(target-commit . ,(assq-ref query-parameters 'target_commit))
|
(scm-alist->streaming-json
|
||||||
(channel-news . ,(list->vector
|
`((base-commit . ,(assq-ref query-parameters 'base_commit))
|
||||||
|
(target-commit . ,(assq-ref query-parameters 'target_commit))
|
||||||
|
(channel-news
|
||||||
|
.
|
||||||
|
,(lambda (port)
|
||||||
|
(list->json-array
|
||||||
|
(match-lambda
|
||||||
|
((commit tag title_text body_text change)
|
||||||
|
`(,@(if (null? commit)
|
||||||
|
'()
|
||||||
|
`((commit . ,commit)))
|
||||||
|
,@(if (null? tag)
|
||||||
|
'()
|
||||||
|
`((tag . ,tag)))
|
||||||
|
(title-text
|
||||||
|
. ,(map
|
||||||
|
(match-lambda
|
||||||
|
((lang . text)
|
||||||
|
(cons
|
||||||
|
lang
|
||||||
|
(texinfo->variants-alist text))))
|
||||||
|
title_text))
|
||||||
|
(body-text
|
||||||
|
. ,(map
|
||||||
|
(match-lambda
|
||||||
|
((lang . text)
|
||||||
|
(cons
|
||||||
|
lang
|
||||||
|
(texinfo->variants-alist text))))
|
||||||
|
body_text))
|
||||||
|
(change . ,change))))
|
||||||
|
(fibers-force channel-news-data-promise)
|
||||||
|
port)))
|
||||||
|
(new-packages
|
||||||
|
.
|
||||||
|
,(lambda (port)
|
||||||
|
(list->json-array
|
||||||
|
identity
|
||||||
|
new-packages
|
||||||
|
port)))
|
||||||
|
(removed-packages
|
||||||
|
.
|
||||||
|
,(lambda (port)
|
||||||
|
(list->json-array
|
||||||
|
identity
|
||||||
|
removed-packages
|
||||||
|
port)))
|
||||||
|
(version-changes
|
||||||
|
. ,(lambda (port)
|
||||||
|
(list->json-array
|
||||||
|
(match-lambda
|
||||||
|
((name data ...)
|
||||||
|
`((name . ,name)
|
||||||
|
,@data)))
|
||||||
|
version-changes
|
||||||
|
port)))
|
||||||
|
(lint_warnings
|
||||||
|
.
|
||||||
|
,(lambda (port)
|
||||||
|
(list->json-array
|
||||||
|
(match-lambda
|
||||||
|
(((package-name package-version)
|
||||||
|
. warnings)
|
||||||
|
|
||||||
|
`((package
|
||||||
|
. ((name . ,package-name)
|
||||||
|
(version . ,package-version)))
|
||||||
|
(warnings
|
||||||
|
. ,(list->vector
|
||||||
(map
|
(map
|
||||||
(match-lambda
|
(match-lambda
|
||||||
((commit tag title_text body_text change)
|
((lint-checker-name
|
||||||
`(,@(if (null? commit)
|
message
|
||||||
'()
|
lint-checker-description
|
||||||
`((commit . ,commit)))
|
lint-checker-network-dependent
|
||||||
,@(if (null? tag)
|
file line column-number
|
||||||
'()
|
change)
|
||||||
`((tag . ,tag)))
|
|
||||||
(title-text
|
|
||||||
. ,(map
|
|
||||||
(match-lambda
|
|
||||||
((lang . text)
|
|
||||||
(cons
|
|
||||||
lang
|
|
||||||
(texinfo->variants-alist text))))
|
|
||||||
title_text))
|
|
||||||
(body-text
|
|
||||||
. ,(map
|
|
||||||
(match-lambda
|
|
||||||
((lang . text)
|
|
||||||
(cons
|
|
||||||
lang
|
|
||||||
(texinfo->variants-alist text))))
|
|
||||||
body_text))
|
|
||||||
(change . ,change))))
|
|
||||||
channel-news-data)))
|
|
||||||
(new-packages . ,(list->vector new-packages))
|
|
||||||
(removed-packages . ,(list->vector removed-packages))
|
|
||||||
(version-changes . ,(list->vector
|
|
||||||
(map
|
|
||||||
(match-lambda
|
|
||||||
((name data ...)
|
|
||||||
`((name . ,name)
|
|
||||||
,@data)))
|
|
||||||
version-changes)))
|
|
||||||
(lint_warnings
|
|
||||||
. ,(list->vector
|
|
||||||
(map
|
|
||||||
(match-lambda
|
|
||||||
(((package-name package-version)
|
|
||||||
. warnings)
|
|
||||||
|
|
||||||
`((package
|
`((change . ,change)
|
||||||
. ((name . ,package-name)
|
(checker
|
||||||
(version . ,package-version)))
|
. ((name . ,lint-checker-name)
|
||||||
(warnings
|
(description
|
||||||
. ,(list->vector
|
. ,lint-checker-description)))
|
||||||
(map
|
(message . ,message)
|
||||||
(match-lambda
|
(location
|
||||||
((lint-checker-name
|
. ((file . ,file)
|
||||||
message
|
(line . ,(string->number line))
|
||||||
lint-checker-description
|
(column . ,(string->number
|
||||||
lint-checker-network-dependent
|
column-number)))))))
|
||||||
file line column-number
|
warnings))))))
|
||||||
change)
|
(fibers-force lint-warnings-data-promise)
|
||||||
|
port))))
|
||||||
`((change . ,change)
|
port))
|
||||||
(checker
|
#:stream? #t
|
||||||
. ((name . ,lint-checker-name)
|
|
||||||
(description
|
|
||||||
. ,lint-checker-description)))
|
|
||||||
(message . ,message)
|
|
||||||
(location
|
|
||||||
. ((file . ,file)
|
|
||||||
(line . ,(string->number line))
|
|
||||||
(column . ,(string->number
|
|
||||||
column-number)))))))
|
|
||||||
warnings))))))
|
|
||||||
lint-warnings-data))))
|
|
||||||
#:extra-headers http-headers-for-unchanging-content))
|
#:extra-headers http-headers-for-unchanging-content))
|
||||||
(else
|
(else
|
||||||
(fibers-let ((lint-warnings-locale-options
|
(fibers-let ((lint-warnings-locale-options
|
||||||
|
|
@ -422,9 +461,9 @@
|
||||||
new-packages
|
new-packages
|
||||||
removed-packages
|
removed-packages
|
||||||
version-changes
|
version-changes
|
||||||
lint-warnings-data
|
(fibers-force lint-warnings-data-promise)
|
||||||
lint-warnings-locale-options
|
lint-warnings-locale-options
|
||||||
channel-news-data)
|
(fibers-force channel-news-data-promise))
|
||||||
#:extra-headers http-headers-for-unchanging-content))))))))))
|
#:extra-headers http-headers-for-unchanging-content))))))))))
|
||||||
|
|
||||||
(define (render-compare-by-datetime mime-types
|
(define (render-compare-by-datetime mime-types
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue