diff options
author | Christopher Baines <mail@cbaines.net> | 2019-08-31 12:42:28 +0100 |
---|---|---|
committer | Christopher Baines <mail@cbaines.net> | 2019-09-01 13:12:10 +0100 |
commit | 75f2c19fc8df76f63b465de6690e1204862804d0 (patch) | |
tree | 70d76e974af8a16085e1279c81ce80bfd620ae4d | |
parent | 6b9977f62eef54678c7a53844ad5d26d8efeecb0 (diff) | |
download | data-service-75f2c19fc8df76f63b465de6690e1204862804d0.tar data-service-75f2c19fc8df76f63b465de6690e1204862804d0.tar.gz |
Add lint-warning-count-by-lint-checker-for-revision
To return counts of lint warnings, grouped by lint checker for a specific
revision.
-rw-r--r-- | guix-data-service/model/lint-checker.scm | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/guix-data-service/model/lint-checker.scm b/guix-data-service/model/lint-checker.scm index 6193966..c6cafde 100644 --- a/guix-data-service/model/lint-checker.scm +++ b/guix-data-service/model/lint-checker.scm @@ -1,8 +1,10 @@ (define-module (guix-data-service model lint-checker) #:use-module (srfi srfi-1) #:use-module (ice-9 match) + #:use-module (squee) #:use-module (guix-data-service model utils) - #:export (lint-checkers->lint-checker-ids)) + #:export (lint-checkers->lint-checker-ids + lint-warning-count-by-lint-checker-for-revision)) (define (lint-checkers->lint-checker-ids conn lint-checkers-data) (insert-missing-data-and-return-all-ids @@ -13,3 +15,25 @@ (description . ,quote-string) (network_dependent . ,value->sql-boolean)) lint-checkers-data)) + +(define (lint-warning-count-by-lint-checker-for-revision conn commit-hash) + (define query + " +SELECT lint_checkers.name, lint_checkers.description, + lint_checkers.network_dependent, revision_data.count +FROM lint_checkers +INNER JOIN ( + SELECT lint_checker_id, COUNT(*) + FROM lint_warnings + WHERE id IN ( + SELECT lint_warning_id + FROM guix_revision_lint_warnings + INNER JOIN guix_revisions + ON guix_revision_lint_warnings.guix_revision_id = guix_revisions.id + WHERE commit = $1 + ) + GROUP BY lint_checker_id +) AS revision_data ON lint_checkers.id = revision_data.lint_checker_id +ORDER BY count DESC") + + (exec-query conn query (list commit-hash))) |