mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-10-04 13:26:30 +00:00
refactor: remove testCaseSummary prop from TableProfiler components and related interfaces
This commit is contained in:
parent
1ca4329483
commit
296bc99c42
@ -30,7 +30,6 @@ import { TestLevel } from '../../../DataQuality/AddDataQualityTest/components/Te
|
|||||||
export interface TableProfilerProps {
|
export interface TableProfilerProps {
|
||||||
permissions: OperationPermission;
|
permissions: OperationPermission;
|
||||||
table?: Table;
|
table?: Table;
|
||||||
testCaseSummary?: TestSummary;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TableProfilerProviderProps extends TableProfilerProps {
|
export interface TableProfilerProviderProps extends TableProfilerProps {
|
||||||
|
@ -33,7 +33,7 @@ import { useTourProvider } from '../../../../context/TourProvider/TourProvider';
|
|||||||
import { TabSpecificField } from '../../../../enums/entity.enum';
|
import { TabSpecificField } from '../../../../enums/entity.enum';
|
||||||
import { Table } from '../../../../generated/entity/data/table';
|
import { Table } from '../../../../generated/entity/data/table';
|
||||||
import { ProfileSampleType } from '../../../../generated/metadataIngestion/databaseServiceProfilerPipeline';
|
import { ProfileSampleType } from '../../../../generated/metadataIngestion/databaseServiceProfilerPipeline';
|
||||||
import { TestCase } from '../../../../generated/tests/testCase';
|
import { TestCase, TestSummary } from '../../../../generated/tests/testCase';
|
||||||
import { Include } from '../../../../generated/type/include';
|
import { Include } from '../../../../generated/type/include';
|
||||||
import { usePaging } from '../../../../hooks/paging/usePaging';
|
import { usePaging } from '../../../../hooks/paging/usePaging';
|
||||||
import useCustomLocation from '../../../../hooks/useCustomLocation/useCustomLocation';
|
import useCustomLocation from '../../../../hooks/useCustomLocation/useCustomLocation';
|
||||||
@ -44,6 +44,7 @@ import {
|
|||||||
} from '../../../../rest/tableAPI';
|
} from '../../../../rest/tableAPI';
|
||||||
import {
|
import {
|
||||||
getListTestCaseBySearch,
|
getListTestCaseBySearch,
|
||||||
|
getTestCaseExecutionSummary,
|
||||||
ListTestCaseParamsBySearch,
|
ListTestCaseParamsBySearch,
|
||||||
} from '../../../../rest/testAPI';
|
} from '../../../../rest/testAPI';
|
||||||
import { bytesToSize } from '../../../../utils/StringsUtils';
|
import { bytesToSize } from '../../../../utils/StringsUtils';
|
||||||
@ -68,7 +69,6 @@ export const TableProfilerProvider = ({
|
|||||||
children,
|
children,
|
||||||
permissions,
|
permissions,
|
||||||
table: tableEntity,
|
table: tableEntity,
|
||||||
testCaseSummary,
|
|
||||||
}: TableProfilerProviderProps) => {
|
}: TableProfilerProviderProps) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { fqn: datasetFQN } = useFqn();
|
const { fqn: datasetFQN } = useFqn();
|
||||||
@ -88,6 +88,7 @@ export const TableProfilerProvider = ({
|
|||||||
const [isTestCaseDrawerOpen, setIsTestCaseDrawerOpen] = useState(false);
|
const [isTestCaseDrawerOpen, setIsTestCaseDrawerOpen] = useState(false);
|
||||||
const [testLevel, setTestLevel] = useState<TestLevel>();
|
const [testLevel, setTestLevel] = useState<TestLevel>();
|
||||||
const [table, setTable] = useState<Table | undefined>(tableEntity);
|
const [table, setTable] = useState<Table | undefined>(tableEntity);
|
||||||
|
const [testCaseSummary, setTestCaseSummary] = useState<TestSummary>();
|
||||||
|
|
||||||
const isTableDeleted = useMemo(() => table?.deleted, [table]);
|
const isTableDeleted = useMemo(() => table?.deleted, [table]);
|
||||||
|
|
||||||
@ -309,6 +310,22 @@ export const TableProfilerProvider = ({
|
|||||||
}
|
}
|
||||||
}, [viewTest, isTourOpen, activeTab, testCasePaging.pageSize]);
|
}, [viewTest, isTourOpen, activeTab, testCasePaging.pageSize]);
|
||||||
|
|
||||||
|
const fetchTestCaseSummary = useCallback(async () => {
|
||||||
|
if (isUndefined(table?.testSuite?.id)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const response = await getTestCaseExecutionSummary(table.testSuite.id);
|
||||||
|
setTestCaseSummary(response);
|
||||||
|
} catch (error) {
|
||||||
|
setTestCaseSummary(undefined);
|
||||||
|
}
|
||||||
|
}, [table?.testSuite?.id]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
fetchTestCaseSummary();
|
||||||
|
}, []);
|
||||||
|
|
||||||
const tableProfilerPropsData: TableProfilerContextInterface = useMemo(() => {
|
const tableProfilerPropsData: TableProfilerContextInterface = useMemo(() => {
|
||||||
return {
|
return {
|
||||||
isTestsLoading,
|
isTestsLoading,
|
||||||
|
@ -59,7 +59,7 @@ import {
|
|||||||
} from '../../generated/entity/feed/suggestion';
|
} from '../../generated/entity/feed/suggestion';
|
||||||
import { Operation } from '../../generated/entity/policies/accessControl/resourcePermission';
|
import { Operation } from '../../generated/entity/policies/accessControl/resourcePermission';
|
||||||
import { PageType } from '../../generated/system/ui/page';
|
import { PageType } from '../../generated/system/ui/page';
|
||||||
import { TestSummary } from '../../generated/tests/testCase';
|
import { TestCaseStatus } from '../../generated/tests/testCase';
|
||||||
import { TagLabel } from '../../generated/type/tagLabel';
|
import { TagLabel } from '../../generated/type/tagLabel';
|
||||||
import LimitWrapper from '../../hoc/LimitWrapper';
|
import LimitWrapper from '../../hoc/LimitWrapper';
|
||||||
import { useApplicationStore } from '../../hooks/useApplicationStore';
|
import { useApplicationStore } from '../../hooks/useApplicationStore';
|
||||||
@ -68,6 +68,7 @@ import { useFqn } from '../../hooks/useFqn';
|
|||||||
import { useSub } from '../../hooks/usePubSub';
|
import { useSub } from '../../hooks/usePubSub';
|
||||||
import { FeedCounts } from '../../interface/feed.interface';
|
import { FeedCounts } from '../../interface/feed.interface';
|
||||||
import { getContractByEntityId } from '../../rest/contractAPI';
|
import { getContractByEntityId } from '../../rest/contractAPI';
|
||||||
|
import { fetchTestCaseResultByTestSuiteId } from '../../rest/dataQualityDashboardAPI';
|
||||||
import { getDataQualityLineage } from '../../rest/lineageAPI';
|
import { getDataQualityLineage } from '../../rest/lineageAPI';
|
||||||
import { getQueriesList } from '../../rest/queryAPI';
|
import { getQueriesList } from '../../rest/queryAPI';
|
||||||
import {
|
import {
|
||||||
@ -78,7 +79,6 @@ import {
|
|||||||
restoreTable,
|
restoreTable,
|
||||||
updateTablesVotes,
|
updateTablesVotes,
|
||||||
} from '../../rest/tableAPI';
|
} from '../../rest/tableAPI';
|
||||||
import { getTestCaseExecutionSummary } from '../../rest/testAPI';
|
|
||||||
import {
|
import {
|
||||||
addToRecentViewed,
|
addToRecentViewed,
|
||||||
getFeedCounts,
|
getFeedCounts,
|
||||||
@ -133,7 +133,6 @@ const TableDetailsPageV1: React.FC = () => {
|
|||||||
const [tablePermissions, setTablePermissions] = useState<OperationPermission>(
|
const [tablePermissions, setTablePermissions] = useState<OperationPermission>(
|
||||||
DEFAULT_ENTITY_PERMISSION
|
DEFAULT_ENTITY_PERMISSION
|
||||||
);
|
);
|
||||||
const [testCaseSummary, setTestCaseSummary] = useState<TestSummary>();
|
|
||||||
const [dqFailureCount, setDqFailureCount] = useState(0);
|
const [dqFailureCount, setDqFailureCount] = useState(0);
|
||||||
const { customizedPage, isLoading } = useCustomPages(PageType.Table);
|
const { customizedPage, isLoading } = useCustomPages(PageType.Table);
|
||||||
const [isTabExpanded, setIsTabExpanded] = useState(false);
|
const [isTabExpanded, setIsTabExpanded] = useState(false);
|
||||||
@ -233,7 +232,7 @@ const TableDetailsPageV1: React.FC = () => {
|
|||||||
}
|
}
|
||||||
}, [tableFqn, viewUsagePermission]);
|
}, [tableFqn, viewUsagePermission]);
|
||||||
|
|
||||||
const fetchDQFailureCount = async () => {
|
const fetchDQUpstreamFailureCount = async () => {
|
||||||
if (!tableClassBase.getAlertEnableStatus()) {
|
if (!tableClassBase.getAlertEnableStatus()) {
|
||||||
setDqFailureCount(0);
|
setDqFailureCount(0);
|
||||||
}
|
}
|
||||||
@ -253,34 +252,38 @@ const TableDetailsPageV1: React.FC = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchTestCaseSummary = async () => {
|
const getTestCaseFailureCount = async () => {
|
||||||
try {
|
try {
|
||||||
if (isUndefined(tableDetails?.testSuite?.id)) {
|
if (!tableClassBase.getAlertEnableStatus()) {
|
||||||
setTestCaseSummary(undefined);
|
setDqFailureCount(0);
|
||||||
await fetchDQFailureCount();
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await getTestCaseExecutionSummary(
|
if (isUndefined(tableDetails?.testSuite?.id)) {
|
||||||
tableDetails?.testSuite?.id
|
await fetchDQUpstreamFailureCount();
|
||||||
);
|
|
||||||
setTestCaseSummary(response);
|
|
||||||
|
|
||||||
const failureCount =
|
return;
|
||||||
response.columnTestSummary?.reduce((acc, curr) => {
|
}
|
||||||
return acc + (curr.failed ?? 0);
|
|
||||||
}, response.failed ?? 0) ??
|
const testSuiteId = tableDetails?.testSuite?.id;
|
||||||
response.failed ??
|
|
||||||
0;
|
const { data } = await fetchTestCaseResultByTestSuiteId(
|
||||||
|
testSuiteId,
|
||||||
|
TestCaseStatus.Failed
|
||||||
|
);
|
||||||
|
const failureCount = data.reduce(
|
||||||
|
(acc, curr) => acc + parseInt(curr.document_count ?? '0'),
|
||||||
|
0
|
||||||
|
);
|
||||||
|
|
||||||
if (failureCount === 0) {
|
if (failureCount === 0) {
|
||||||
await fetchDQFailureCount();
|
await fetchDQUpstreamFailureCount();
|
||||||
} else {
|
} else {
|
||||||
setDqFailureCount(failureCount);
|
setDqFailureCount(failureCount);
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
setTestCaseSummary(undefined);
|
setDqFailureCount(0);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -551,7 +554,6 @@ const TableDetailsPageV1: React.FC = () => {
|
|||||||
viewProfilerPermission,
|
viewProfilerPermission,
|
||||||
editLineagePermission,
|
editLineagePermission,
|
||||||
fetchTableDetails,
|
fetchTableDetails,
|
||||||
testCaseSummary,
|
|
||||||
isViewTableType,
|
isViewTableType,
|
||||||
labelMap: tabLabelMap,
|
labelMap: tabLabelMap,
|
||||||
});
|
});
|
||||||
@ -581,7 +583,6 @@ const TableDetailsPageV1: React.FC = () => {
|
|||||||
viewProfilerPermission,
|
viewProfilerPermission,
|
||||||
editLineagePermission,
|
editLineagePermission,
|
||||||
fetchTableDetails,
|
fetchTableDetails,
|
||||||
testCaseSummary,
|
|
||||||
isViewTableType,
|
isViewTableType,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@ -787,7 +788,7 @@ const TableDetailsPageV1: React.FC = () => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (tableDetails) {
|
if (tableDetails) {
|
||||||
fetchQueryCount();
|
fetchQueryCount();
|
||||||
fetchTestCaseSummary();
|
getTestCaseFailureCount();
|
||||||
}
|
}
|
||||||
}, [tableDetails?.fullyQualifiedName]);
|
}, [tableDetails?.fullyQualifiedName]);
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ import {
|
|||||||
buildMustEsFilterForOwner,
|
buildMustEsFilterForOwner,
|
||||||
buildMustEsFilterForTags,
|
buildMustEsFilterForTags,
|
||||||
} from '../utils/DataQuality/DataQualityUtils';
|
} from '../utils/DataQuality/DataQualityUtils';
|
||||||
import { getDataQualityReport } from './testAPI';
|
import { DataQualityReportParamsType, getDataQualityReport } from './testAPI';
|
||||||
|
|
||||||
export const fetchEntityCoveredWithDQ = (
|
export const fetchEntityCoveredWithDQ = (
|
||||||
filters?: DataQualityDashboardChartFilters,
|
filters?: DataQualityDashboardChartFilters,
|
||||||
@ -274,3 +274,59 @@ export const fetchTestCaseStatusMetricsByDays = (
|
|||||||
'bucketName=byDay:aggType=date_histogram:field=timestamp&calendar_interval=day,bucketName=newIncidents:aggType=cardinality:field=testCase.fullyQualifiedName',
|
'bucketName=byDay:aggType=date_histogram:field=timestamp&calendar_interval=day,bucketName=newIncidents:aggType=cardinality:field=testCase.fullyQualifiedName',
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const fetchTestCaseResultByTestSuiteId = (
|
||||||
|
testSuiteId: string,
|
||||||
|
status?: TestCaseStatus
|
||||||
|
) => {
|
||||||
|
const params: DataQualityReportParamsType = {
|
||||||
|
q: JSON.stringify({
|
||||||
|
query: {
|
||||||
|
bool: {
|
||||||
|
must: [
|
||||||
|
{
|
||||||
|
bool: {
|
||||||
|
should: [
|
||||||
|
{
|
||||||
|
nested: {
|
||||||
|
path: 'testSuites',
|
||||||
|
query: {
|
||||||
|
term: {
|
||||||
|
'testSuites.id': testSuiteId,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
term: {
|
||||||
|
'testSuite.id': testSuiteId,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
term: {
|
||||||
|
deleted: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
...(status
|
||||||
|
? [
|
||||||
|
{
|
||||||
|
term: {
|
||||||
|
'testCaseResult.testCaseStatus': status,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]
|
||||||
|
: []),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
aggregationQuery:
|
||||||
|
'bucketName=entityLinks:aggType=terms:field=entityLink.nonNormalized,bucketName=status_counts:aggType=terms:field=testCaseResult.testCaseStatus',
|
||||||
|
index: 'testCase',
|
||||||
|
};
|
||||||
|
|
||||||
|
return getDataQualityReport(params);
|
||||||
|
};
|
||||||
|
@ -25,7 +25,6 @@ import { DetailPageWidgetKeys } from '../enums/CustomizeDetailPage.enum';
|
|||||||
import { EntityTabs } from '../enums/entity.enum';
|
import { EntityTabs } from '../enums/entity.enum';
|
||||||
import { Table } from '../generated/entity/data/table';
|
import { Table } from '../generated/entity/data/table';
|
||||||
import { Tab } from '../generated/system/ui/uiCustomization';
|
import { Tab } from '../generated/system/ui/uiCustomization';
|
||||||
import { TestSummary } from '../generated/tests/testCase';
|
|
||||||
import { FeedCounts } from '../interface/feed.interface';
|
import { FeedCounts } from '../interface/feed.interface';
|
||||||
import { WidgetConfig } from '../pages/CustomizablePage/CustomizablePage.interface';
|
import { WidgetConfig } from '../pages/CustomizablePage/CustomizablePage.interface';
|
||||||
import i18n from './i18next/LocalUtil';
|
import i18n from './i18next/LocalUtil';
|
||||||
@ -49,7 +48,6 @@ export interface TableDetailPageTabProps {
|
|||||||
editCustomAttributePermission: boolean;
|
editCustomAttributePermission: boolean;
|
||||||
deleted?: boolean;
|
deleted?: boolean;
|
||||||
tableDetails?: Table;
|
tableDetails?: Table;
|
||||||
testCaseSummary?: TestSummary;
|
|
||||||
getEntityFeedCount: () => void;
|
getEntityFeedCount: () => void;
|
||||||
fetchTableDetails: () => Promise<void>;
|
fetchTableDetails: () => Promise<void>;
|
||||||
handleFeedCount: (data: FeedCounts) => void;
|
handleFeedCount: (data: FeedCounts) => void;
|
||||||
|
@ -766,7 +766,6 @@ export const getTableDetailPageBaseTabs = ({
|
|||||||
viewQueriesPermission,
|
viewQueriesPermission,
|
||||||
editLineagePermission,
|
editLineagePermission,
|
||||||
fetchTableDetails,
|
fetchTableDetails,
|
||||||
testCaseSummary,
|
|
||||||
isViewTableType,
|
isViewTableType,
|
||||||
labelMap,
|
labelMap,
|
||||||
}: TableDetailPageTabProps): TabProps[] => {
|
}: TableDetailPageTabProps): TabProps[] => {
|
||||||
@ -881,11 +880,7 @@ export const getTableDetailPageBaseTabs = ({
|
|||||||
),
|
),
|
||||||
key: EntityTabs.PROFILER,
|
key: EntityTabs.PROFILER,
|
||||||
children: (
|
children: (
|
||||||
<TableProfiler
|
<TableProfiler permissions={tablePermissions} table={tableDetails} />
|
||||||
permissions={tablePermissions}
|
|
||||||
table={tableDetails}
|
|
||||||
testCaseSummary={testCaseSummary}
|
|
||||||
/>
|
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user