Skip to content

Commit

Permalink
fix: tree list query was count builds multiple times
Browse files Browse the repository at this point in the history
  • Loading branch information
lfjnascimento committed Jul 5, 2024
1 parent 0e80db6 commit 76e2ea6
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions backend/kernelCI_app/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ def get(self, _):
f"""
SELECT
checkouts.git_commit_hash AS id,
COUNT(CASE WHEN builds.valid = true THEN 1 END) AS valid_builds,
COUNT(CASE WHEN builds.valid = false THEN 1 END) AS invalid_builds,
SUM(CASE WHEN builds.valid IS NULL AND builds.id IS NOT NULL THEN 1 ELSE 0 END)
COUNT(DISTINCT CASE WHEN builds.valid = true THEN builds.id END) AS valid_builds,
COUNT(DISTINCT CASE WHEN builds.valid = false THEN builds.id END) AS invalid_builds,
COUNT(DISTINCT CASE WHEN builds.valid IS NULL AND builds.id IS NOT NULL THEN builds.id END)
AS null_builds,
COUNT(builds.id) AS total_builds,
COUNT(DISTINCT builds.id) AS total_builds,
COUNT(CASE WHEN tests.status = 'FAIL' THEN 1 END) AS fail_tests,
COUNT(CASE WHEN tests.status = 'ERROR' THEN 1 END) AS error_tests,
COUNT(CASE WHEN tests.status = 'MISS' THEN 1 END) AS miss_tests,
Expand All @@ -36,8 +36,7 @@ def get(self, _):
builds ON builds.checkout_id = checkouts.id
LEFT JOIN
tests ON tests.build_id = builds.id
WHERE
checkouts.git_commit_hash IN ({placeholders})
WHERE checkouts.git_commit_hash IN ({placeholders})
GROUP BY
checkouts.git_commit_hash;
""",
Expand Down

0 comments on commit 76e2ea6

Please sign in to comment.