Skip to content

Commit

Permalink
feat: add endpoint to get trees
Browse files Browse the repository at this point in the history
  • Loading branch information
lfjnascimento committed Jul 2, 2024
1 parent 486e80a commit dcb7e65
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 3 deletions.
3 changes: 2 additions & 1 deletion backend/kernelCI/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
"""

from django.contrib import admin
from django.urls import path
from django.urls import path, include

urlpatterns = [
path("admin/", admin.site.urls),
path('api/', include('kernelCI_app.urls')),
]
14 changes: 14 additions & 0 deletions backend/kernelCI_app/serializers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from rest_framework import serializers
from kernelCI_app.models import Checkouts


class CheckoutsSerializer(serializers.ModelSerializer):
class Meta:
model = Checkouts
fields = [
'field_timestamp', 'id', 'origin', 'tree_name',
'git_repository_url', 'git_commit_hash', 'git_commit_name',
'git_repository_branch', 'patchset_files', 'patchset_hash',
'message_id', 'comment', 'start_time', 'contacts',
'log_url', 'log_excerpt', 'valid', 'misc'
]
7 changes: 7 additions & 0 deletions backend/kernelCI_app/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from django.urls import path
from kernelCI_app import views


urlpatterns = [
path('tree/', views.TreeView.as_view(), name='tree')
]
52 changes: 50 additions & 2 deletions backend/kernelCI_app/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,51 @@
# from django.shortcuts import render
from django.http import JsonResponse
from django.views import View

# Create your views here.
from kernelCI_app.models import Checkouts
from kernelCI_app.serializers import CheckoutsSerializer


class TreeView(View):

def get(self, _):
checkout_ids = config.keys()
checkouts = Checkouts.objects.filter(id__in=checkout_ids)
serializer = CheckoutsSerializer(checkouts, many=True)
for d in serializer.data:
d.update(config.get(d["id"]))

return JsonResponse(serializer.data, safe=False)


config = {
"broonie:7592653346c84691a16ccd1c115df05c": {
"tree_name": "mainline",
"build_status": {"finished": 160, "total": 182},
"test_status": {"finished": 182, "total": 182},
},
"broonie:170e93ec1178448293bb3b1163b1a4ee": {
"tree_name": "stable",
"build_status": {"finished": 182, "total": 182},
"test_status": {"finished": 820, "total": 820},
},
"broonie:88964264010d43159ffa28bb524be058": {
"tree_name": "stable",
"build_status": {"finished": 160, "total": 182},
"test_status": {"finished": 642, "total": 820}
},
"broonie:12f55b2668fb4eca9254bfadad4ee871": {
"tree_name": "stable",
"build_status": {"finished": 182, "total": 182},
"test_status": {"finished": 820, "total": 820}
},
"broonie:c4ea3368208f4909b5af51c6a148047d": {
"tree_name": "stable",
"build_status": {"finished": 182, "total": 182},
"test_status": {"finished": 820, "total": 820}
},
"broonie:1b17e613a3e94254af6fef1167572d35": {
"tree_name": "stable",
"build_status": {"finished": 182, "total": 182},
"test_status": {"finished": 820, "total": 820}
},
}

0 comments on commit dcb7e65

Please sign in to comment.