-
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.
Showing
10 changed files
with
304 additions
and
10 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,60 @@ | ||
from typing import Dict, Optional | ||
from django.http import HttpResponseBadRequest, HttpResponseNotFound, JsonResponse | ||
from django.views import View | ||
from kernelCI_app.models import Incidents | ||
from kernelCI_app.utils import getErrorResponseBody | ||
|
||
|
||
class IssueDetailsBuilds(View): | ||
def _fetch_incidents(self, *, issue_id: str, version: int) -> Optional[Dict]: | ||
fields = [ | ||
"build__id", | ||
"build__architecture", | ||
"build__config_name", | ||
"build__valid", | ||
"build__start_time", | ||
"build__duration", | ||
"build__compiler", | ||
] | ||
|
||
builds = Incidents.objects.filter( | ||
issue_id=issue_id, issue_version=version | ||
).values(*fields) | ||
|
||
return [ | ||
{ | ||
"id": build["build__id"], | ||
"architecture": build["build__architecture"], | ||
"config_name": build["build__config_name"], | ||
"valid": build["build__valid"], | ||
"start_time": build["build__start_time"], | ||
"duration": build["build__duration"], | ||
"compiler": build["build__compiler"], | ||
} | ||
for build in builds | ||
] | ||
|
||
def get(self, _request, issue_id: Optional[str], version: Optional[str]): | ||
missing_params = [] | ||
if issue_id is None: | ||
missing_params.append("issue_id") | ||
if version is None: | ||
missing_params.append("version") | ||
if len(missing_params) != 0: | ||
return HttpResponseBadRequest( | ||
getErrorResponseBody("Missing parameters: ", missing_params) | ||
) | ||
|
||
try: | ||
parsed_version = int(version) | ||
except ValueError: | ||
return HttpResponseBadRequest( | ||
getErrorResponseBody("Invalid version parameter, must be an integer") | ||
) | ||
|
||
builds_data = self._fetch_incidents(issue_id=issue_id, version=parsed_version) | ||
|
||
if builds_data is None: | ||
return HttpResponseNotFound(getErrorResponseBody("Builds not found")) | ||
|
||
return JsonResponse(builds_data, safe=False) |
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,53 @@ | ||
http http://localhost:8000/api/issue/maestro:f61865c29254c199ba015e5f48acfc070aff0eb0/version/0/builds | ||
|
||
# HTTP/1.1 200 OK | ||
# Cache-Control: max-age=0 | ||
# Content-Length: 872 | ||
# Content-Type: application/json | ||
# Cross-Origin-Opener-Policy: same-origin | ||
# Date: Mon, 23 Dec 2024 19:25:24 GMT | ||
# Expires: Mon, 23 Dec 2024 19:25:24 GMT | ||
# Referrer-Policy: same-origin | ||
# Server: WSGIServer/0.2 CPython/3.12.7 | ||
# Vary: origin | ||
# X-Content-Type-Options: nosniff | ||
# X-Frame-Options: DENY | ||
|
||
# [ | ||
# { | ||
# "architecture": "arm", | ||
# "compiler": "clang-17", | ||
# "config_name": "imx_v6_v7_defconfig+allmodconfig", | ||
# "duration": null, | ||
# "id": "maestro:673fcc50923416c0c98dfea6", | ||
# "start_time": "2024-11-22T00:12:00.124Z", | ||
# "valid": false | ||
# }, | ||
# { | ||
# "architecture": "arm", | ||
# "compiler": "clang-17", | ||
# "config_name": "imx_v6_v7_defconfig+allmodconfig", | ||
# "duration": null, | ||
# "id": "maestro:67406b8c923416c0c98f75ad", | ||
# "start_time": "2024-11-22T11:31:24.629Z", | ||
# "valid": false | ||
# }, | ||
# { | ||
# "architecture": "arm", | ||
# "compiler": "clang-17", | ||
# "config_name": "imx_v6_v7_defconfig+allmodconfig", | ||
# "duration": null, | ||
# "id": "maestro:67409557923416c0c98fa534", | ||
# "start_time": "2024-11-22T14:29:43.011Z", | ||
# "valid": false | ||
# }, | ||
# { | ||
# "architecture": "arm", | ||
# "compiler": "clang-17", | ||
# "config_name": "imx_v6_v7_defconfig+allmodconfig", | ||
# "duration": null, | ||
# "id": "maestro:674079b4923416c0c98f79ba", | ||
# "start_time": "2024-11-22T12:31:48.309Z", | ||
# "valid": false | ||
# } | ||
# ] |
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
73 changes: 73 additions & 0 deletions
73
dashboard/src/components/IssueDetails/IssueDetailsBuildSection.tsx
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,73 @@ | ||
import type { LinkProps } from '@tanstack/react-router'; | ||
|
||
import { useIntl } from 'react-intl'; | ||
|
||
import { useMemo } from 'react'; | ||
|
||
import { Separator } from '@/components/ui/separator'; | ||
import { MemoizedSectionError } from '@/components/DetailsPages/SectionError'; | ||
import type { | ||
AccordionItemBuilds, | ||
BuildsTableFilter, | ||
TableFilter, | ||
} from '@/types/tree/TreeDetails'; | ||
|
||
import { useIssueDetailsBuilds } from '@/api/issueDetails'; | ||
|
||
import { BuildsTable } from '@/components/BuildsTable/BuildsTable'; | ||
import { sanitizeBuildTable } from '@/utils/utils'; | ||
|
||
interface IIssueDetailsBuildSection { | ||
issueId?: string; | ||
versionNumber?: string; | ||
buildTableFilter: TableFilter['buildsTable']; | ||
onClickFilter: (filter: BuildsTableFilter) => void; | ||
getTableRowLink: (testId: string) => LinkProps; | ||
} | ||
|
||
export const IssueDetailsBuildSection = ({ | ||
issueId, | ||
versionNumber, | ||
buildTableFilter, | ||
onClickFilter, | ||
getTableRowLink, | ||
}: IIssueDetailsBuildSection): JSX.Element => { | ||
const { data, error, isLoading } = useIssueDetailsBuilds( | ||
issueId ?? '', | ||
versionNumber ?? '', | ||
); | ||
|
||
const { formatMessage } = useIntl(); | ||
|
||
const buildData = useMemo((): AccordionItemBuilds[] => { | ||
if (!data) { | ||
return []; | ||
} | ||
return sanitizeBuildTable(data); | ||
}, [data]); | ||
|
||
return ( | ||
<> | ||
<h2 className="text-2xl font-bold"> | ||
{formatMessage({ id: 'global.builds' })} | ||
</h2> | ||
<Separator className="my-6 bg-darkGray" /> | ||
{data ? ( | ||
<div className="flex flex-col gap-6"> | ||
<BuildsTable | ||
tableKey="issueDetailsBuilds" | ||
buildItems={buildData} | ||
filter={buildTableFilter} | ||
getRowLink={getTableRowLink} | ||
onClickFilter={onClickFilter} | ||
/> | ||
</div> | ||
) : ( | ||
<MemoizedSectionError | ||
isLoading={isLoading} | ||
errorMessage={error?.message} | ||
/> | ||
)} | ||
</> | ||
); | ||
}; |
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.