mirror of
git://git.savannah.gnu.org/guix/data-service.git
synced 2023-12-14 03:23:03 +01:00
Add option to change language of lint messages for the revision page
Signed-off-by: Christopher Baines <mail@cbaines.net>
This commit is contained in:
parent
a50bc3342f
commit
e514471fc9
|
@ -21,7 +21,7 @@
|
|||
#:use-module (guix-data-service database)
|
||||
#:use-module (guix-data-service model utils)
|
||||
#:export (lint-warning-message-data->lint-warning-message-ids
|
||||
|
||||
lint-warning-message-locales-for-revision
|
||||
lint-warning-message-data->lint-warning-message-set-id))
|
||||
|
||||
(define (lint-warning-message-data->lint-warning-message-ids conn
|
||||
|
@ -73,3 +73,19 @@
|
|||
(((id)) id)
|
||||
(()
|
||||
(insert-lint-warning-message-set conn lint-warning-message-ids))))))
|
||||
|
||||
(define (lint-warning-message-locales-for-revision conn commit-hash)
|
||||
(exec-query
|
||||
conn
|
||||
"SELECT DISTINCT lint_warning_messages.locale
|
||||
from lint_warning_messages
|
||||
INNER JOIN lint_warning_message_sets
|
||||
ON lint_warning_messages.id = ANY (lint_warning_message_sets.message_ids)
|
||||
INNER JOIN lint_warnings
|
||||
ON lint_warning_message_sets.id = lint_warnings.lint_warning_message_set_id
|
||||
INNER JOIN guix_revision_lint_warnings
|
||||
ON lint_warnings.id = guix_revision_lint_warnings.lint_warning_id
|
||||
INNER JOIN guix_revisions
|
||||
ON guix_revision_lint_warnings.guix_revision_id = guix_revisions.id
|
||||
WHERE guix_revisions.commit = $1"
|
||||
(list commit-hash)))
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
|
||||
(define* (lint-warnings-for-guix-revision conn commit-hash
|
||||
#:key
|
||||
locale
|
||||
package-query
|
||||
linters
|
||||
message-query)
|
||||
|
@ -72,8 +73,9 @@ INNER 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'
|
||||
AND lint_warning_messages.id = ANY (lint_warning_message_sets.message_ids)
|
||||
ON lint_warning_messages.locale = "
|
||||
"'" locale "'"
|
||||
" AND lint_warning_messages.id = ANY (lint_warning_message_sets.message_ids)
|
||||
"
|
||||
(if linters
|
||||
(string-append
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
#:use-module (guix-data-service model package-metadata)
|
||||
#:use-module (guix-data-service model lint-checker)
|
||||
#:use-module (guix-data-service model lint-warning)
|
||||
#:use-module (guix-data-service model lint-warning-message)
|
||||
#:use-module (guix-data-service model guix-revision)
|
||||
#:use-module (guix-data-service model system-test)
|
||||
#:use-module (guix-data-service model nar)
|
||||
|
@ -269,7 +270,8 @@
|
|||
(let ((parsed-query-parameters
|
||||
(parse-query-parameters
|
||||
request
|
||||
`((package_query ,identity)
|
||||
`((locale ,identity #:default "en_US.utf8")
|
||||
(package_query ,identity)
|
||||
(linter ,identity #:multi-value)
|
||||
(message_query ,identity)
|
||||
(field ,identity #:multi-value
|
||||
|
@ -916,6 +918,13 @@
|
|||
name)))
|
||||
(lint-checkers-for-revision conn commit-hash)))
|
||||
|
||||
(define lint-warnings-locale-options
|
||||
(map
|
||||
(match-lambda
|
||||
((locale)
|
||||
locale))
|
||||
(lint-warning-message-locales-for-revision conn commit-hash)))
|
||||
|
||||
(if (any-invalid-query-parameters? query-parameters)
|
||||
(case (most-appropriate-mime-type
|
||||
'(application/json text/html)
|
||||
|
@ -930,11 +939,13 @@
|
|||
'()
|
||||
'()
|
||||
lint-checker-options
|
||||
lint-warnings-locale-options
|
||||
#:path-base path-base
|
||||
#:header-text header-text
|
||||
#:header-link header-link))))
|
||||
|
||||
(let* ((package-query (assq-ref query-parameters 'package_query))
|
||||
(let* ((locale (assq-ref query-parameters 'locale))
|
||||
(package-query (assq-ref query-parameters 'package_query))
|
||||
(linters (assq-ref query-parameters 'linter))
|
||||
(message-query (assq-ref query-parameters 'message_query))
|
||||
(fields (assq-ref query-parameters 'field))
|
||||
|
@ -943,6 +954,7 @@
|
|||
commit-hash))
|
||||
(lint-warnings
|
||||
(lint-warnings-for-guix-revision conn commit-hash
|
||||
#:locale locale
|
||||
#:package-query package-query
|
||||
#:linters linters
|
||||
#:message-query message-query)))
|
||||
|
@ -980,6 +992,7 @@
|
|||
lint-warnings
|
||||
git-repositories
|
||||
lint-checker-options
|
||||
lint-warnings-locale-options
|
||||
#:path-base path-base
|
||||
#:header-text header-text
|
||||
#:header-link header-link)
|
||||
|
|
|
@ -1454,6 +1454,7 @@ figure {
|
|||
lint-warnings
|
||||
git-repositories
|
||||
lint-checker-options
|
||||
lint-warnings-locale-options
|
||||
#:key path-base
|
||||
header-text header-link)
|
||||
(define field-options
|
||||
|
@ -1487,6 +1488,12 @@ figure {
|
|||
(action "")
|
||||
(style "padding-bottom: 0")
|
||||
(class "form-horizontal"))
|
||||
,(form-horizontal-control
|
||||
"Locale" query-parameters
|
||||
#:options lint-warnings-locale-options
|
||||
#:allow-selecting-multiple-options #f
|
||||
#:help-text
|
||||
"Language")
|
||||
,(form-horizontal-control
|
||||
"Package query" query-parameters
|
||||
#:help-text
|
||||
|
|
Loading…
Reference in a new issue