Skip to content

Commit

Permalink
feat: add buildDetails endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
lfjnascimento committed Jul 24, 2024
1 parent 89f845d commit efaf42c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
3 changes: 2 additions & 1 deletion backend/kernelCI_app/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@

urlpatterns = [
path('tree/', views.TreeView.as_view(), name='tree'),
path('tree/<str:commit_hash>', views.TreeDetails.as_view(), name='treeDetails')
path('tree/<str:commit_hash>', views.TreeDetails.as_view(), name='treeDetails'),
path('build/<str:build_id>', views.BuildDetails.as_view(), name='buildDetails')
]
24 changes: 24 additions & 0 deletions backend/kernelCI_app/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit efaf42c

Please sign in to comment.