From efaf42ced090c098fcf0b8ef6167503a3da3de88 Mon Sep 17 00:00:00 2001 From: lfjnascimento Date: Wed, 24 Jul 2024 15:46:07 -0300 Subject: [PATCH] feat: add buildDetails endpoint --- backend/kernelCI_app/urls.py | 3 ++- backend/kernelCI_app/views.py | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/backend/kernelCI_app/urls.py b/backend/kernelCI_app/urls.py index 0ee011cad..9ca6b758a 100644 --- a/backend/kernelCI_app/urls.py +++ b/backend/kernelCI_app/urls.py @@ -4,5 +4,6 @@ urlpatterns = [ path('tree/', views.TreeView.as_view(), name='tree'), - path('tree/', views.TreeDetails.as_view(), name='treeDetails') + path('tree/', views.TreeDetails.as_view(), name='treeDetails'), + path('build/', views.BuildDetails.as_view(), name='buildDetails') ] diff --git a/backend/kernelCI_app/views.py b/backend/kernelCI_app/views.py index 5684ecb87..d16a308b4 100644 --- a/backend/kernelCI_app/views.py +++ b/backend/kernelCI_app/views.py @@ -141,3 +141,27 @@ def get(self, request, commit_hash): summary = self.create_summary(records) return JsonResponse({"builds": records, "summary": summary}, safe=False) + + +class BuildDetails(View): + + def get(self, request, build_id): + build_fields = [ + "id", "_timestamp", "checkout_id", "origin", + "comment", "start_time", "duration", "architecture", + "command", "compiler", "config_name", "config_url", + "log_url", "valid", "misc"] + + query = Query().from_table(Builds, build_fields) + query.join( + 'checkouts', + fields=[ + 'git_repository_branch', 'git_commit_name', 'git_repository_url', 'git_commit_hash' + ], + condition='checkouts.id = builds.checkout_id', + ) + query.where(**{'builds.id__eq': build_id}) + + records = query.select() + result = records[0] if records else {} + return JsonResponse(result, safe=False)