diff options
author | Christopher Baines <mail@cbaines.net> | 2019-09-01 12:38:38 +0100 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2019-09-01 13:12:10 +0100 |
commit | 3544f9300f92654ef21bc091147a86cc04ea701b (patch) | |
tree | 628549d3773f976b184569460e9b3fcef98ac904 /guix-data-service | |
parent | 07f368a54be46a10edbc205b22dc502438d0605b (diff) | |
download | data-service-3544f9300f92654ef21bc091147a86cc04ea701b.tar data-service-3544f9300f92654ef21bc091147a86cc04ea701b.tar.gz |
Add lint-warnings-for-guix-revision to the lint-warning module
Diffstat (limited to 'guix-data-service')
-rw-r--r-- | guix-data-service/model/lint-warning.scm | 50 |
1 files changed, 49 insertions, 1 deletions
diff --git a/guix-data-service/model/lint-warning.scm b/guix-data-service/model/lint-warning.scm index e516618..0b82a62 100644 --- a/guix-data-service/model/lint-warning.scm +++ b/guix-data-service/model/lint-warning.scm @@ -2,7 +2,8 @@ #:use-module (squee) #:use-module (guix-data-service model utils) #:export (lint-warnings-data->lint-warning-ids - insert-guix-revision-lint-warnings)) + insert-guix-revision-lint-warnings + lint-warnings-for-guix-revision)) (define (lint-warnings-data->lint-warning-ids conn @@ -34,3 +35,50 @@ guix-revision-id)) lint-warning-ids) ", ")))) + +(define* (lint-warnings-for-guix-revision conn commit-hash + #:key + package-query + linters + message-query) + (define query + (string-append " +SELECT lint_warnings.id, lint_checkers.name, lint_checkers.description, + lint_checkers.network_dependent, packages.name, packages.version, + locations.file, locations.line, locations.column_number, + lint_warning_messages.message +FROM lint_warnings +INNER JOIN lint_checkers + ON lint_warnings.lint_checker_id = lint_checkers.id +INNER JOIN packages + ON lint_warnings.package_id = packages.id +INNER JOIN locations + ON locations.id = lint_warnings.location_id +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) +WHERE lint_warnings.id IN ( + SELECT lint_warning_id + FROM guix_revision_lint_warnings + INNER JOIN guix_revisions ON guix_revision_id = guix_revisions.id + WHERE commit = $1 +)" + (if package-query + " AND to_tsvector(packages.name) @@ plainto_tsquery($2)" + "") + (if message-query + (simple-format + #f " AND to_tsvector(lint_warning_messages.message) @@ plainto_tsquery($~A)" + (if package-query "3" "2")) + "") + " ORDER BY packages.name")) + + (exec-query conn query `(,commit-hash + ,@(if package-query + (list package-query) + '()) + ,@(if message-query + (list message-query) + '())))) |