aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--guix-data-service/model/lint-checker.scm26
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)))