Skip to content

Commit

Permalink
refactor(tree-details): alter response fields
Browse files Browse the repository at this point in the history
- Changed response fields to snake case
- Changed response structure
- Added the necessary types to the front-end
- Made the necessary changes in the front-end because of the new
  response structure

Part of #731
Part of #700
  • Loading branch information
murilx committed Jan 17, 2025
1 parent c5dabdf commit e890f2e
Show file tree
Hide file tree
Showing 6 changed files with 120 additions and 102 deletions.
62 changes: 36 additions & 26 deletions backend/kernelCI_app/views/treeDetailsView.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,33 +165,43 @@ def get(self, request, commit_hash: str | None):

return JsonResponse(
{
"bootArchSummary": list(self.bootArchSummary.values()),
"testArchSummary": list(self.test_arch_summary.values()),
"buildsSummary": self.build_summary,
"bootFailReasons": self.bootFailReasons,
"testFailReasons": self.testFailReasons,
"testPlatformsWithErrors": list(self.testPlatformsWithErrors),
"bootPlatformsFailing": list(self.bootPlatformsFailing),
"testConfigs": self.test_configs,
"bootConfigs": self.bootConfigs,
"testStatusSummary": self.testStatusSummary,
"bootStatusSummary": self.bootStatusSummary,
"bootHistory": self.bootHistory,
"testHistory": self.testHistory,
"bootIssues": self.bootIssues,
"testIssues": self.testIssues,
"testEnvironmentCompatible": self.testEnvironmentCompatible,
"bootEnvironmentCompatible": self.bootEnvironmentCompatible,
"testEnvironmentMisc": self.testEnvironmentMisc,
"bootEnvironmentMisc": self.bootEnvironmentMisc,
"hardwareUsed": list(self.hardwareUsed),
"failedTestsWithUnknownIssues": self.failedTestsWithUnknownIssues,
"failedBootsWithUnknownIssues": self.failedBootsWithUnknownIssues,
"builds": self.builds,
"buildsIssues": self.build_issues,
"failedBuildsWithUnknownIssues": self.failed_builds_with_unknown_issues,
"treeUrl": self.tree_url,
"git_commit_tags": self.git_commit_tags,
"boots": self.bootHistory,
"tests": self.testHistory,
"summary": {
"builds": {
"status": self.build_summary["builds"],
"architectures": self.build_summary["architectures"],
"configs": self.build_summary["configs"],
"issues": self.build_issues,
"unknown_issues": self.failed_builds_with_unknown_issues,
},
"boots": {
"status": self.bootStatusSummary,
"architectures": list(self.bootArchSummary.values()),
"configs": self.bootConfigs,
"issues": self.bootIssues,
"unknown_issues": self.failedBootsWithUnknownIssues,
"enviroment_compatible": self.bootEnvironmentCompatible,
"enviroment_misc": self.bootEnvironmentMisc,
"fail_reasons": self.bootFailReasons,
"failed_platforms": list(self.bootPlatformsFailing),
},
"tests": {
"status": self.testStatusSummary,
"architectures": list(self.test_arch_summary.values()),
"configs": self.test_configs,
"issues": self.testIssues,
"unknown_issues": self.failedTestsWithUnknownIssues,
"enviroment_compatible": self.testEnvironmentCompatible,
"enviroment_misc": self.testEnvironmentMisc,
"fail_reasons": self.testFailReasons,
"failed_platforms": list(self.testPlatformsWithErrors),
},
"hardware": list(self.hardwareUsed),
"tree_url": self.tree_url,
"git_commit_tags": self.git_commit_tags,
},
},
safe=False,
)
33 changes: 18 additions & 15 deletions dashboard/src/pages/TreeDetails/Tabs/Boots/BootsTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,13 @@ const BootsTab = ({ reqFilter }: BootsTabProps): JSX.Element => {

const hardwareData = useMemo(() => {
return {
...data?.bootEnvironmentCompatible,
...data?.bootEnvironmentMisc,
...data?.summary.boots.enviroment_compatible,
...data?.summary.boots.enviroment_misc,
};
}, [data?.bootEnvironmentCompatible, data?.bootEnvironmentMisc]);
}, [
data?.summary.boots.enviroment_compatible,
data?.summary.boots.enviroment_misc,
]);

if (error || !treeId) {
return (
Expand All @@ -121,7 +124,7 @@ const BootsTab = ({ reqFilter }: BootsTabProps): JSX.Element => {

if (!data) return <div />;

if (data.bootHistory.length < 1) {
if (data.boots.length < 1) {
return (
<BaseCard
title={<FormattedMessage id="bootsTab.info" />}
Expand All @@ -140,22 +143,22 @@ const BootsTab = ({ reqFilter }: BootsTabProps): JSX.Element => {
<div>
<MemoizedStatusCard
title={<FormattedMessage id="bootsTab.bootStatus" />}
statusCounts={data.bootStatusSummary}
statusCounts={data.summary.boots.status}
/>
<MemoizedConfigList
title={<FormattedMessage id="bootsTab.configs" />}
configStatusCounts={data.bootConfigs}
configStatusCounts={data.summary.boots.configs}
diffFilter={diffFilter}
/>
<MemoizedErrorsSummary
title={<FormattedMessage id="global.summary" />}
archCompilerErrors={data.bootArchSummary}
archCompilerErrors={data.summary.boots.architectures}
diffFilter={diffFilter}
/>
<MemoizedIssuesList
title={<FormattedMessage id="global.issues" />}
issues={data.bootIssues}
failedWithUnknownIssues={data.failedBootsWithUnknownIssues}
issues={data.summary.boots.issues}
failedWithUnknownIssues={data.summary.boots.unknown_issues}
diffFilter={diffFilter}
issueFilterSection="bootIssue"
detailsId={treeId}
Expand All @@ -174,25 +177,25 @@ const BootsTab = ({ reqFilter }: BootsTabProps): JSX.Element => {
<MobileGrid>
<MemoizedStatusCard
title={<FormattedMessage id="bootsTab.bootStatus" />}
statusCounts={data.bootStatusSummary}
statusCounts={data.summary.boots.status}
/>
<TreeCommitNavigationGraph />
<InnerMobileGrid>
<div>
<MemoizedConfigList
title={<FormattedMessage id="bootsTab.configs" />}
configStatusCounts={data.bootConfigs}
configStatusCounts={data.summary.boots.configs}
diffFilter={diffFilter}
/>
<MemoizedErrorsSummary
title={<FormattedMessage id="global.summary" />}
archCompilerErrors={data.bootArchSummary}
archCompilerErrors={data.summary.boots.architectures}
diffFilter={diffFilter}
/>
<MemoizedIssuesList
title={<FormattedMessage id="global.issues" />}
issues={data.bootIssues}
failedWithUnknownIssues={data.failedBootsWithUnknownIssues}
issues={data.summary.boots.issues}
failedWithUnknownIssues={data.summary.boots.unknown_issues}
diffFilter={diffFilter}
issueFilterSection="bootIssue"
detailsId={treeId}
Expand All @@ -212,7 +215,7 @@ const BootsTab = ({ reqFilter }: BootsTabProps): JSX.Element => {
tableKey="treeDetailsBoots"
filter={tableFilter.bootsTable}
onClickFilter={onClickFilter}
testHistory={data.bootHistory}
testHistory={data.boots}
getRowLink={getRowLink}
updatePathFilter={updatePathFilter}
currentPathFilter={currentPathFilter}
Expand Down
33 changes: 18 additions & 15 deletions dashboard/src/pages/TreeDetails/Tabs/Tests/TestsTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,13 @@ const TestsTab = ({ reqFilter }: TestsTabProps): JSX.Element => {

const hardwareData = useMemo(() => {
return {
...data?.testEnvironmentCompatible,
...data?.testEnvironmentMisc,
...data?.summary.tests.enviroment_compatible,
...data?.summary.tests.enviroment_misc,
};
}, [data?.testEnvironmentCompatible, data?.testEnvironmentMisc]);
}, [
data?.summary.tests.enviroment_compatible,
data?.summary.tests.enviroment_misc,
]);

if (error || !treeId) {
return (
Expand All @@ -123,7 +126,7 @@ const TestsTab = ({ reqFilter }: TestsTabProps): JSX.Element => {

if (!data) return <div />;

if (data.testHistory.length < 1) {
if (data.tests.length < 1) {
return (
<BaseCard
title={<FormattedMessage id="global.info" />}
Expand All @@ -142,22 +145,22 @@ const TestsTab = ({ reqFilter }: TestsTabProps): JSX.Element => {
<div>
<MemoizedStatusCard
title={<FormattedMessage id="testsTab.testStatus" />}
statusCounts={data.testStatusSummary}
statusCounts={data.summary.tests.status}
/>
<MemoizedConfigList
title={<FormattedMessage id="global.configs" />}
configStatusCounts={data.testConfigs}
configStatusCounts={data.summary.tests.configs}
diffFilter={diffFilter}
/>
<MemoizedErrorsSummary
title={<FormattedMessage id="global.summary" />}
archCompilerErrors={data.testArchSummary}
archCompilerErrors={data.summary.tests.architectures}
diffFilter={diffFilter}
/>
<MemoizedIssuesList
title={<FormattedMessage id="global.issues" />}
issues={data.testIssues}
failedWithUnknownIssues={data.failedTestsWithUnknownIssues}
issues={data.summary.tests.issues}
failedWithUnknownIssues={data.summary.tests.unknown_issues}
diffFilter={diffFilter}
issueFilterSection="testIssue"
detailsId={treeId}
Expand All @@ -176,25 +179,25 @@ const TestsTab = ({ reqFilter }: TestsTabProps): JSX.Element => {
<MobileGrid>
<MemoizedStatusCard
title={<FormattedMessage id="testsTab.testStatus" />}
statusCounts={data.testStatusSummary}
statusCounts={data.summary.tests.status}
/>
<TreeCommitNavigationGraph />
<InnerMobileGrid>
<div>
<MemoizedConfigList
title={<FormattedMessage id="global.configs" />}
configStatusCounts={data.testConfigs}
configStatusCounts={data.summary.tests.configs}
diffFilter={diffFilter}
/>
<MemoizedErrorsSummary
title={<FormattedMessage id="global.summary" />}
archCompilerErrors={data.testArchSummary}
archCompilerErrors={data.summary.tests.architectures}
diffFilter={diffFilter}
/>
<MemoizedIssuesList
title={<FormattedMessage id="global.issues" />}
issues={data.testIssues}
failedWithUnknownIssues={data.failedTestsWithUnknownIssues}
issues={data.summary.tests.issues}
failedWithUnknownIssues={data.summary.tests.unknown_issues}
diffFilter={diffFilter}
issueFilterSection="testIssue"
detailsId={treeId}
Expand All @@ -213,7 +216,7 @@ const TestsTab = ({ reqFilter }: TestsTabProps): JSX.Element => {

<TestsTable
tableKey="treeDetailsTests"
testHistory={data.testHistory}
testHistory={data.tests}
onClickFilter={onClickFilter}
filter={tableFilter.testsTable}
getRowLink={getRowLink}
Expand Down
24 changes: 12 additions & 12 deletions dashboard/src/pages/TreeDetails/TreeDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,10 @@ function TreeDetails(): JSX.Element {
);

const tabsCounts: TreeDetailsTabRightElement = useMemo(() => {
const { valid, invalid } = data?.buildsSummary.builds ?? {};
const { testStatusSummary } = data ?? {};
const { valid, invalid } = data?.summary.builds.status ?? {};
const { status: testStatusSummary } = data?.summary.tests ?? {};

const { bootStatusSummary } = data ?? {};
const { status: bootStatusSummary } = data?.summary.boots ?? {};

return {
'global.tests': testStatusSummary ? (
Expand Down Expand Up @@ -226,12 +226,12 @@ function TreeDetails(): JSX.Element {

const treeDetailsData: ITreeDetails = useMemo(
() => ({
architectures: sanitizeArchs(data?.buildsSummary.architectures),
configs: sanitizeConfigs(data?.buildsSummary.configs),
architectures: sanitizeArchs(data?.summary.builds.architectures),
configs: sanitizeConfigs(data?.summary.builds.configs),
builds: sanitizeBuilds(data?.builds),
buildsSummary: sanitizeBuildsSummary(data?.buildsSummary.builds),
buildsIssues: data?.buildsIssues || [],
failedBuildsWithUnknownIssues: data?.failedBuildsWithUnknownIssues,
buildsSummary: sanitizeBuildsSummary(data?.summary.builds.status),
buildsIssues: data?.summary.builds.issues || [],
failedBuildsWithUnknownIssues: data?.summary.builds.unknown_issues,
}),
[data],
);
Expand Down Expand Up @@ -279,7 +279,7 @@ function TreeDetails(): JSX.Element {
gitUrl={treeInfo?.gitUrl}
commitHash={treeId}
commitName={treeInfo?.commitName}
commitTags={data?.git_commit_tags}
commitTags={data?.summary.git_commit_tags}
/>
</div>
<QuerySwitcher
Expand All @@ -290,18 +290,18 @@ function TreeDetails(): JSX.Element {
<div className="mt-5">
<MemoizedHardwareUsed
title={<FormattedMessage id="treeDetails.hardwareUsed" />}
hardwareUsed={data?.hardwareUsed}
hardwareUsed={data?.summary.hardware}
diffFilter={diffFilter}
/>
</div>
</QuerySwitcher>
<div className="flex flex-col pb-2">
{data?.treeUrl && (
{data?.summary.tree_url && (
<div className="sticky top-[4.5rem] z-10">
<div className="absolute right-0 top-2 py-4">
<TreeDetailsFilter
paramFilter={diffFilter}
treeUrl={data.treeUrl}
treeUrl={data.summary.tree_url}
/>
</div>
</div>
Expand Down
8 changes: 4 additions & 4 deletions dashboard/src/pages/TreeDetails/TreeDetailsFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ export const createFilter = (data: TTreeTestsFullData | undefined): TFilter => {
compilers[b.compiler ?? 'Unknown'] = false;
});

data.hardwareUsed.forEach(h => (hardware[h] = false));
data.summary.hardware.forEach(h => (hardware[h] = false));

data.buildsIssues.forEach(i => (buildIssue[i.id] = false));
data.bootIssues.forEach(i => (bootIssue[i.id] = false));
data.testIssues.forEach(i => (testIssue[i.id] = false));
data.summary.builds.issues.forEach(i => (buildIssue[i.id] = false));
data.summary.boots.issues.forEach(i => (bootIssue[i.id] = false));
data.summary.tests.issues.forEach(i => (testIssue[i.id] = false));
}

return {
Expand Down
Loading

0 comments on commit e890f2e

Please sign in to comment.