Use lint checker related translations on some pages
Signed-off-by: Christopher Baines <mail@cbaines.net>
This commit is contained in:
parent
b8abe38352
commit
d3096de655
|
@ -598,9 +598,10 @@ ORDER BY coalesce(base_packages.name, target_packages.name) ASC, base_packages.v
|
|||
target-derivations)))))))))
|
||||
names-and-versions)))
|
||||
|
||||
(define (lint-warning-differences-data conn
|
||||
(define* (lint-warning-differences-data conn
|
||||
base-guix-revision-id
|
||||
target-guix-revision-id)
|
||||
target-guix-revision-id
|
||||
locale)
|
||||
(define query
|
||||
(string-append "
|
||||
WITH base_lint_warnings AS (
|
||||
|
@ -620,18 +621,19 @@ WITH base_lint_warnings AS (
|
|||
ON lint_checkers.lint_checker_description_set_id = lint_checker_description_sets.id
|
||||
INNER JOIN lint_checker_descriptions
|
||||
ON lint_checker_descriptions.id = ANY (lint_checker_description_sets.description_ids)
|
||||
AND lint_checker_descriptions.locale = $3
|
||||
INNER JOIN locations
|
||||
ON lint_warnings.location_id = locations.id
|
||||
INNER JOIN lint_warning_message_sets
|
||||
ON lint_warnings.lint_warning_message_set_id = lint_warning_message_sets.id
|
||||
INNER JOIN lint_warning_messages
|
||||
ON lint_warning_messages.id = ANY (lint_warning_message_sets.message_ids) AND
|
||||
lint_warning_messages.locale = 'en_US.utf8'
|
||||
lint_warning_messages.locale = $3
|
||||
WHERE lint_warnings.id IN (
|
||||
SELECT lint_warning_id
|
||||
FROM guix_revision_lint_warnings
|
||||
WHERE guix_revision_id = $1
|
||||
)
|
||||
SELECT lint_warning_id
|
||||
FROM guix_revision_lint_warnings
|
||||
WHERE guix_revision_id = $1
|
||||
)
|
||||
), target_lint_warnings AS (
|
||||
SELECT lint_warnings.id,
|
||||
packages.name, packages.version,
|
||||
|
@ -649,18 +651,19 @@ WITH base_lint_warnings AS (
|
|||
ON lint_checkers.lint_checker_description_set_id = lint_checker_description_sets.id
|
||||
INNER JOIN lint_checker_descriptions
|
||||
ON lint_checker_descriptions.id = ANY (lint_checker_description_sets.description_ids)
|
||||
INNER JOIN locations
|
||||
AND lint_checker_descriptions.locale = $3"
|
||||
"INNER JOIN locations
|
||||
ON lint_warnings.location_id = locations.id
|
||||
INNER JOIN lint_warning_message_sets
|
||||
ON lint_warnings.lint_warning_message_set_id = lint_warning_message_sets.id
|
||||
INNER JOIN lint_warning_messages
|
||||
ON lint_warning_messages.id = ANY (lint_warning_message_sets.message_ids) AND
|
||||
lint_warning_messages.locale = 'en_US.utf8'
|
||||
WHERE lint_warnings.id IN (
|
||||
SELECT lint_warning_id
|
||||
FROM guix_revision_lint_warnings
|
||||
WHERE guix_revision_id = $2
|
||||
)
|
||||
ON lint_warning_messages.id = ANY (lint_warning_message_sets.message_ids)
|
||||
AND lint_warning_messages.locale = $3"
|
||||
" WHERE lint_warnings.id IN (
|
||||
SELECT lint_warning_id
|
||||
FROM guix_revision_lint_warnings
|
||||
WHERE guix_revision_id = $2
|
||||
)
|
||||
)
|
||||
SELECT coalesce(
|
||||
base_lint_warnings.name,
|
||||
|
@ -728,7 +731,8 @@ ORDER BY coalesce(base_lint_warnings.name, target_lint_warnings.name) ASC, base_
|
|||
|
||||
(exec-query conn query
|
||||
(list base-guix-revision-id
|
||||
target-guix-revision-id)))
|
||||
target-guix-revision-id
|
||||
locale)))
|
||||
|
||||
(define (channel-news-differences-data conn
|
||||
base-guix-revision-id
|
||||
|
|
|
@ -92,6 +92,7 @@ INNER JOIN lint_checker_description_sets
|
|||
ON lint_checkers.lint_checker_description_set_id = lint_checker_description_sets.id
|
||||
INNER JOIN lint_checker_descriptions
|
||||
ON lint_checker_descriptions.id = ANY (lint_checker_description_sets.description_ids)
|
||||
AND lint_checker_descriptions.locale = 'en_US.utf8'
|
||||
INNER JOIN (
|
||||
SELECT lint_checker_id, COUNT(*)
|
||||
FROM lint_warnings
|
||||
|
@ -136,11 +137,11 @@ INNER JOIN lint_checker_description_sets
|
|||
ON lint_checkers.lint_checker_description_set_id = lint_checker_description_sets.id
|
||||
INNER JOIN lint_checker_descriptions
|
||||
ON lint_checker_descriptions.id = ANY (lint_checker_description_sets.description_ids)
|
||||
AND lint_checker_descriptions.locale = 'en_US.utf8'
|
||||
WHERE lint_checkers.id IN (
|
||||
SELECT lint_checker_id
|
||||
FROM guix_revision_lint_checkers
|
||||
INNER JOIN guix_revisions
|
||||
ON guix_revisions.id = guix_revision_lint_checkers.guix_revision_id
|
||||
WHERE commit = $1
|
||||
)"
|
||||
WHERE commit = $1)"
|
||||
(list commit-hash)))
|
||||
|
|
|
@ -72,7 +72,9 @@ INNER JOIN lint_checker_description_sets
|
|||
ON lint_checkers.lint_checker_description_set_id = lint_checker_description_sets.id
|
||||
INNER JOIN lint_checker_descriptions
|
||||
ON lint_checker_descriptions.id = ANY (lint_checker_description_sets.description_ids)
|
||||
INNER JOIN packages
|
||||
AND lint_checker_descriptions.locale = "
|
||||
"'" locale "' "
|
||||
"INNER JOIN packages
|
||||
ON lint_warnings.package_id = packages.id
|
||||
INNER JOIN locations
|
||||
ON locations.id = lint_warnings.location_id
|
||||
|
@ -118,11 +120,13 @@ INNER JOIN lint_warning_messages
|
|||
(list message-query)
|
||||
'()))))
|
||||
|
||||
(define (select-lint-warnings-by-revision-package-name-and-version conn
|
||||
(define* (select-lint-warnings-by-revision-package-name-and-version conn
|
||||
commit-hash
|
||||
name version)
|
||||
(define query "
|
||||
SELECT lint_warnings.id, lint_checkers.name, lint_checker_descriptions.description,
|
||||
name version
|
||||
#:key
|
||||
locale)
|
||||
(define query
|
||||
"SELECT lint_warnings.id, lint_checkers.name, lint_checker_descriptions.description,
|
||||
lint_checkers.network_dependent,
|
||||
locations.file, locations.line, locations.column_number,
|
||||
lint_warning_messages.message
|
||||
|
@ -133,6 +137,7 @@ INNER JOIN lint_checker_description_sets
|
|||
ON lint_checkers.lint_checker_description_set_id = lint_checker_description_sets.id
|
||||
INNER JOIN lint_checker_descriptions
|
||||
ON lint_checker_descriptions.id = ANY (lint_checker_description_sets.description_ids)
|
||||
AND lint_checker_descriptions.locale = $4
|
||||
INNER JOIN packages
|
||||
ON lint_warnings.package_id = packages.id
|
||||
LEFT OUTER JOIN locations
|
||||
|
@ -140,7 +145,7 @@ LEFT OUTER JOIN locations
|
|||
INNER JOIN lint_warning_message_sets
|
||||
ON lint_warning_message_sets.id = lint_warning_message_set_id
|
||||
INNER JOIN lint_warning_messages
|
||||
ON lint_warning_messages.locale = 'en_US.utf8'
|
||||
ON lint_warning_messages.locale = $4
|
||||
AND lint_warning_messages.id = ANY (lint_warning_message_sets.message_ids)
|
||||
WHERE packages.id IN (
|
||||
SELECT package_derivations.package_id
|
||||
|
@ -157,4 +162,4 @@ WHERE packages.id IN (
|
|||
|
||||
(exec-query conn
|
||||
query
|
||||
(list commit-hash name version)))
|
||||
(list commit-hash name version locale)))
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#:use-module (guix-data-service model guix-revision)
|
||||
#:use-module (guix-data-service model derivation)
|
||||
#:use-module (guix-data-service model build-status)
|
||||
#:use-module (guix-data-service model lint-warning-message)
|
||||
#:use-module (guix-data-service web compare html)
|
||||
#:export (compare-controller))
|
||||
|
||||
|
@ -72,7 +73,8 @@
|
|||
(parse-query-parameters
|
||||
request
|
||||
`((base_commit ,(parse-commit conn) #:required)
|
||||
(target_commit ,(parse-commit conn) #:required)))))
|
||||
(target_commit ,(parse-commit conn) #:required)
|
||||
(locale ,identity #:default "en_US.utf8")))))
|
||||
(render-compare mime-types
|
||||
conn
|
||||
parsed-query-parameters)))
|
||||
|
@ -83,7 +85,8 @@
|
|||
`((base_branch ,identity #:required)
|
||||
(base_datetime ,parse-datetime #:required)
|
||||
(target_branch ,identity #:required)
|
||||
(target_datetime ,parse-datetime #:required)))))
|
||||
(target_datetime ,parse-datetime #:required)
|
||||
(locale ,identity #:default "en_US.utf8")))))
|
||||
(render-compare-by-datetime mime-types
|
||||
conn
|
||||
parsed-query-parameters)))
|
||||
|
@ -147,6 +150,14 @@
|
|||
(define (render-compare mime-types
|
||||
conn
|
||||
query-parameters)
|
||||
(define lint-warnings-locale-options
|
||||
(map
|
||||
(match-lambda
|
||||
((locale)
|
||||
locale))
|
||||
(lint-warning-message-locales-for-revision
|
||||
conn (assq-ref query-parameters 'target_commit))))
|
||||
|
||||
(if (any-invalid-query-parameters? query-parameters)
|
||||
(case (most-appropriate-mime-type
|
||||
'(application/json text/html)
|
||||
|
@ -172,7 +183,8 @@
|
|||
(assq-ref query-parameters 'base_commit)))
|
||||
(target-revision-id (commit->revision-id
|
||||
conn
|
||||
(assq-ref query-parameters 'target_commit))))
|
||||
(assq-ref query-parameters 'target_commit)))
|
||||
(locale (assq-ref query-parameters 'locale)))
|
||||
(let-values
|
||||
(((base-packages-vhash target-packages-vhash)
|
||||
(package-data->package-data-vhashes
|
||||
|
@ -193,7 +205,8 @@
|
|||
2
|
||||
(lint-warning-differences-data conn
|
||||
base-revision-id
|
||||
target-revision-id)))
|
||||
target-revision-id
|
||||
locale)))
|
||||
(channel-news-data
|
||||
(channel-news-differences-data conn
|
||||
base-revision-id
|
||||
|
@ -252,6 +265,7 @@
|
|||
removed-packages
|
||||
version-changes
|
||||
lint-warnings-data
|
||||
lint-warnings-locale-options
|
||||
channel-news-data)
|
||||
#:extra-headers http-headers-for-unchanging-content))))))))
|
||||
|
||||
|
@ -281,11 +295,19 @@
|
|||
(let ((base-branch (assq-ref query-parameters 'base_branch))
|
||||
(base-datetime (assq-ref query-parameters 'base_datetime))
|
||||
(target-branch (assq-ref query-parameters 'target_branch))
|
||||
(target-datetime (assq-ref query-parameters 'target_datetime)))
|
||||
(target-datetime (assq-ref query-parameters 'target_datetime))
|
||||
(locale (assq-ref query-parameters 'locale)))
|
||||
(let* ((base-revision-details
|
||||
(select-guix-revision-for-branch-and-datetime conn
|
||||
base-branch
|
||||
base-datetime))
|
||||
(lint-warnings-locale-options
|
||||
(map
|
||||
(match-lambda
|
||||
((locale)
|
||||
locale))
|
||||
(lint-warning-message-locales-for-revision
|
||||
conn (second base-revision-details))))
|
||||
(base-revision-id
|
||||
(first base-revision-details))
|
||||
(target-revision-details
|
||||
|
@ -314,7 +336,8 @@
|
|||
2
|
||||
(lint-warning-differences-data conn
|
||||
base-revision-id
|
||||
target-revision-id)))
|
||||
target-revision-id
|
||||
locale)))
|
||||
(channel-news-data
|
||||
(channel-news-differences-data conn
|
||||
base-revision-id
|
||||
|
@ -382,6 +405,7 @@
|
|||
removed-packages
|
||||
version-changes
|
||||
lint-warnings-data
|
||||
lint-warnings-locale-options
|
||||
channel-news-data)
|
||||
#:extra-headers http-headers-for-unchanging-content)))))))))
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
removed-packages
|
||||
version-changes
|
||||
lint-warnings-data
|
||||
lint-warnings-locale-options
|
||||
channel-news-data)
|
||||
(define base-commit
|
||||
(assq-ref query-parameters 'base_commit))
|
||||
|
@ -43,9 +44,13 @@
|
|||
(define target-commit
|
||||
(assq-ref query-parameters 'target_commit))
|
||||
|
||||
(define locale
|
||||
(assq-ref query-parameters 'locale))
|
||||
|
||||
(define query-params
|
||||
(string-append "?base_commit=" base-commit
|
||||
"&target_commit=" target-commit))
|
||||
"&target_commit=" target-commit
|
||||
"&locale=" locale))
|
||||
|
||||
(layout
|
||||
#:body
|
||||
|
@ -79,14 +84,62 @@
|
|||
(a (@ (class "btn btn-default")
|
||||
(href ,(string-append "/compare/derivations" query-params)))
|
||||
"Compare derivations"))))
|
||||
|
||||
(div
|
||||
(@ (class "row"))
|
||||
(div
|
||||
(@ (class "col-md-12"))
|
||||
(div
|
||||
(@ (class "well"))
|
||||
(form
|
||||
(@ (method "get")
|
||||
(action "")
|
||||
(style "padding-bottom: 0")
|
||||
(class "form-horizontal"))
|
||||
,(form-horizontal-control
|
||||
"" query-parameters
|
||||
#:name "base_commit"
|
||||
#:type "hidden")
|
||||
,(form-horizontal-control
|
||||
"" query-parameters
|
||||
#:name "target_commit"
|
||||
#:type "hidden")
|
||||
,(form-horizontal-control
|
||||
"" query-parameters
|
||||
#:name "base_branch"
|
||||
#:type "hidden")
|
||||
,(form-horizontal-control
|
||||
"" query-parameters
|
||||
#:name "base_datetime"
|
||||
#:type "hidden")
|
||||
,(form-horizontal-control
|
||||
"" query-parameters
|
||||
#:name "target_branch"
|
||||
#:type "hidden")
|
||||
,(form-horizontal-control
|
||||
"" query-parameters
|
||||
#:name "target_datetime"
|
||||
#:type "hidden")
|
||||
,(form-horizontal-control
|
||||
"Locale" query-parameters
|
||||
#:name "locale"
|
||||
#:allow-selecting-multiple-options #f
|
||||
#:options lint-warnings-locale-options
|
||||
#:help-text "Language")
|
||||
(div (@ (class "form-group form-group-lg"))
|
||||
(div (@ (class "col-sm-offset-2 col-sm-10"))
|
||||
(button (@ (type "submit")
|
||||
(class "btn btn-lg btn-primary"))
|
||||
"Update results")))))))
|
||||
(div
|
||||
(@ (class "row") (style "clear: left;"))
|
||||
(div
|
||||
(@ (class "col-sm-12"))
|
||||
(a (@ (class "btn btn-default btn-lg")
|
||||
(a (@ (class "btn btn-default btn-lg pull-right")
|
||||
(href ,(string-append
|
||||
"/compare.json" query-params)))
|
||||
"View JSON")))
|
||||
|
||||
(div
|
||||
(@ (class "row"))
|
||||
(div
|
||||
|
|
|
@ -258,13 +258,18 @@
|
|||
commit-hash))))
|
||||
(('GET "repository" repository-id "branch" branch-name "latest-processed-revision" "package" name version)
|
||||
(let ((commit-hash
|
||||
(latest-processed-commit-for-branch conn repository-id branch-name)))
|
||||
(latest-processed-commit-for-branch conn repository-id branch-name))
|
||||
(parsed-query-parameters
|
||||
(parse-query-parameters
|
||||
request
|
||||
`((locale ,identity #:default "en_US.utf8")))))
|
||||
(if commit-hash
|
||||
(render-revision-package-version mime-types
|
||||
conn
|
||||
commit-hash
|
||||
name
|
||||
version
|
||||
parsed-query-parameters
|
||||
#:header-text
|
||||
`("Latest processed revision for branch "
|
||||
(samp ,branch-name))
|
||||
|
|
|
@ -157,11 +157,16 @@
|
|||
commit-hash)))
|
||||
(('GET "revision" commit-hash "package" name version)
|
||||
(if (guix-commit-exists? conn commit-hash)
|
||||
(render-revision-package-version mime-types
|
||||
conn
|
||||
commit-hash
|
||||
name
|
||||
version)
|
||||
(let ((parsed-query-parameters
|
||||
(parse-query-parameters
|
||||
request
|
||||
`((locale ,identity #:default "en_US.utf8")))))
|
||||
(render-revision-package-version mime-types
|
||||
conn
|
||||
commit-hash
|
||||
name
|
||||
version
|
||||
parsed-query-parameters))
|
||||
(render-unknown-revision mime-types
|
||||
conn
|
||||
commit-hash)))
|
||||
|
@ -287,7 +292,7 @@
|
|||
(let ((parsed-query-parameters
|
||||
(parse-query-parameters
|
||||
request
|
||||
`((locale ,identity #:default "en_US.utf8")
|
||||
`((locale ,identity #:default "en_US.utf8")
|
||||
(package_query ,identity)
|
||||
(linter ,identity #:multi-value)
|
||||
(message_query ,identity)
|
||||
|
@ -667,6 +672,7 @@
|
|||
commit-hash
|
||||
name
|
||||
version
|
||||
query-parameters
|
||||
#:key
|
||||
(header-text
|
||||
`("Revision "
|
||||
|
@ -675,7 +681,15 @@
|
|||
(string-append
|
||||
"/revision/" commit-hash))
|
||||
version-history-link)
|
||||
(let ((metadata
|
||||
|
||||
(define lint-warnings-locale-options
|
||||
(map
|
||||
(match-lambda
|
||||
((locale)
|
||||
locale))
|
||||
(lint-warning-message-locales-for-revision conn commit-hash)))
|
||||
|
||||
(let* ((metadata
|
||||
(select-package-metadata-by-revision-name-and-version
|
||||
conn
|
||||
commit-hash
|
||||
|
@ -690,12 +704,14 @@
|
|||
(git-repositories
|
||||
(git-repositories-containing-commit conn
|
||||
commit-hash))
|
||||
(locale (assq-ref query-parameters 'locale))
|
||||
(lint-warnings
|
||||
(select-lint-warnings-by-revision-package-name-and-version
|
||||
conn
|
||||
commit-hash
|
||||
name
|
||||
version)))
|
||||
version
|
||||
#:locale locale)))
|
||||
(case (most-appropriate-mime-type
|
||||
'(application/json text/html)
|
||||
mime-types)
|
||||
|
@ -725,6 +741,8 @@
|
|||
derivations
|
||||
git-repositories
|
||||
lint-warnings
|
||||
query-parameters
|
||||
lint-warnings-locale-options
|
||||
#:header-text header-text
|
||||
#:header-link header-link
|
||||
#:version-history-link
|
||||
|
|
|
@ -161,6 +161,8 @@
|
|||
package-metadata
|
||||
derivations git-repositories
|
||||
lint-warnings
|
||||
query-parameters
|
||||
locale-options
|
||||
#:key header-text
|
||||
header-link
|
||||
version-history-link)
|
||||
|
@ -175,6 +177,28 @@
|
|||
(@ (class "col-sm-12"))
|
||||
(h3 (a (@ (href ,header-link))
|
||||
,@header-text))))
|
||||
(div
|
||||
(@ (class "row"))
|
||||
(div
|
||||
(@ (class "col-md-12"))
|
||||
(div
|
||||
(@ (class "well"))
|
||||
(form
|
||||
(@ (method "get")
|
||||
(action "")
|
||||
(style "padding-bottom: 0")
|
||||
(class "form-horizontal"))
|
||||
,(form-horizontal-control
|
||||
"Locale" query-parameters
|
||||
#:options locale-options
|
||||
#:allow-selecting-multiple-options #f
|
||||
#:help-text
|
||||
"Language")
|
||||
(div (@ (class "form-group form-group-lg"))
|
||||
(div (@ (class "col-sm-offset-2 col-sm-10"))
|
||||
(button (@ (type "submit")
|
||||
(class "btn btn-lg btn-primary"))
|
||||
"Update results")))))))
|
||||
(div
|
||||
(@ (class "row"))
|
||||
(div
|
||||
|
|
Loading…
Reference in New Issue