-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(performance): move build status count to on demand
- Added a new endpoint to fetch build status counts - Created `BuildStatusCountView` in `views/buildStatusCountView.py` - Updated `urls.py` to include the new endpoint - Modified `TreeDetails.tsx` to use the new endpoint - Updated `Accordion` component to display build status counts - Refactored `TreeDetails` related types and hooks
- Loading branch information
Showing
10 changed files
with
255 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
from django.http import JsonResponse | ||
from rest_framework.views import APIView | ||
from kernelCI_app.models import Builds | ||
|
||
|
||
class BuildStatusCountView(APIView): | ||
def get(self, _request, build_id): | ||
builds = Builds.objects.raw( | ||
""" | ||
SELECT | ||
builds.id, | ||
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, | ||
COUNT(CASE WHEN tests.status = 'PASS' THEN 1 END) AS pass_tests, | ||
COUNT(CASE WHEN tests.status = 'DONE' THEN 1 END) AS done_tests, | ||
COUNT(CASE WHEN tests.status = 'SKIP' THEN 1 END) AS skip_tests, | ||
SUM(CASE WHEN tests.status IS NULL AND tests.id IS NOT NULL THEN 1 ELSE 0 END) | ||
AS null_tests, | ||
COUNT(tests.id) AS total_tests | ||
FROM | ||
builds | ||
LEFT JOIN | ||
tests ON tests.build_id = builds.id | ||
WHERE builds.id = %s | ||
GROUP BY builds.id; | ||
""", | ||
[build_id], | ||
) | ||
|
||
build_status_counts = list(builds) | ||
if not build_status_counts: | ||
return JsonResponse({"error": "Build not found"}, status=404) | ||
|
||
build_status = build_status_counts[0] | ||
build_counts = { | ||
"build_id": build_status.id, | ||
"fail_tests": build_status.fail_tests, | ||
"error_tests": build_status.error_tests, | ||
"miss_tests": build_status.miss_tests, | ||
"pass_tests": build_status.pass_tests, | ||
"done_tests": build_status.done_tests, | ||
"skip_tests": build_status.skip_tests, | ||
"null_tests": build_status.null_tests, | ||
"total_tests": build_status.total_tests, | ||
} | ||
|
||
return JsonResponse({"build_counts": build_counts}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.