mirror of
https://github.com/datahub-project/datahub.git
synced 2025-12-13 02:57:03 +00:00
fix(siblings) Display sibling assertions in Validations tab (#5268)
* fix(siblings) Display sibling assertions in Validations tab * query changes Co-authored-by: Chris Collins <chriscollins@Chriss-MBP-2-192.lan>
This commit is contained in:
parent
3a08325177
commit
9fd314f92f
@ -48,7 +48,7 @@ const customMerge = (isPrimary, key) => {
|
|||||||
if (key === 'platform') {
|
if (key === 'platform') {
|
||||||
return (a, b) => (isPrimary ? b : a);
|
return (a, b) => (isPrimary ? b : a);
|
||||||
}
|
}
|
||||||
if (key === 'tags' || key === 'terms') {
|
if (key === 'tags' || key === 'terms' || key === 'assertions') {
|
||||||
return (a, b) => {
|
return (a, b) => {
|
||||||
return merge(a, b, {
|
return merge(a, b, {
|
||||||
customMerge: customMerge.bind({}, isPrimary),
|
customMerge: customMerge.bind({}, isPrimary),
|
||||||
|
|||||||
@ -9,6 +9,7 @@ import { DatasetAssertionsList } from './DatasetAssertionsList';
|
|||||||
import { DatasetAssertionsSummary } from './DatasetAssertionsSummary';
|
import { DatasetAssertionsSummary } from './DatasetAssertionsSummary';
|
||||||
import { sortAssertions } from './assertionUtils';
|
import { sortAssertions } from './assertionUtils';
|
||||||
import { TestResults } from './TestResults';
|
import { TestResults } from './TestResults';
|
||||||
|
import { combineEntityDataWithSiblings } from '../../../siblingUtils';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a status summary for the assertions associated with a Dataset.
|
* Returns a status summary for the assertions associated with a Dataset.
|
||||||
@ -47,28 +48,30 @@ enum ViewType {
|
|||||||
export const ValidationsTab = () => {
|
export const ValidationsTab = () => {
|
||||||
const { urn, entityData } = useEntityData();
|
const { urn, entityData } = useEntityData();
|
||||||
const { data, refetch } = useGetDatasetAssertionsQuery({ variables: { urn } });
|
const { data, refetch } = useGetDatasetAssertionsQuery({ variables: { urn } });
|
||||||
|
const combinedData = combineEntityDataWithSiblings(data);
|
||||||
const [removedUrns, setRemovedUrns] = useState<string[]>([]);
|
const [removedUrns, setRemovedUrns] = useState<string[]>([]);
|
||||||
/**
|
/**
|
||||||
* Determines which view should be visible: assertions or tests.
|
* Determines which view should be visible: assertions or tests.
|
||||||
*/
|
*/
|
||||||
const [view, setView] = useState(ViewType.ASSERTIONS);
|
const [view, setView] = useState(ViewType.ASSERTIONS);
|
||||||
|
|
||||||
const assertions = (data && data.dataset?.assertions?.assertions?.map((assertion) => assertion as Assertion)) || [];
|
const assertions =
|
||||||
const maybeTotalAssertions = data?.dataset?.assertions?.total || undefined;
|
(combinedData && combinedData.dataset?.assertions?.assertions?.map((assertion) => assertion as Assertion)) ||
|
||||||
const effectiveTotalAssertions = maybeTotalAssertions || 0;
|
[];
|
||||||
const filteredAssertions = assertions.filter((assertion) => !removedUrns.includes(assertion.urn));
|
const filteredAssertions = assertions.filter((assertion) => !removedUrns.includes(assertion.urn));
|
||||||
|
const numAssertions = filteredAssertions.length;
|
||||||
|
|
||||||
const passingTests = (entityData as any)?.testResults?.passing || [];
|
const passingTests = (entityData as any)?.testResults?.passing || [];
|
||||||
const maybeFailingTests = (entityData as any)?.testResults?.failing || [];
|
const maybeFailingTests = (entityData as any)?.testResults?.failing || [];
|
||||||
const totalTests = maybeFailingTests.length + passingTests.length;
|
const totalTests = maybeFailingTests.length + passingTests.length;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (totalTests > 0 && maybeTotalAssertions === 0) {
|
if (totalTests > 0 && numAssertions === 0) {
|
||||||
setView(ViewType.TESTS);
|
setView(ViewType.TESTS);
|
||||||
} else {
|
} else {
|
||||||
setView(ViewType.ASSERTIONS);
|
setView(ViewType.ASSERTIONS);
|
||||||
}
|
}
|
||||||
}, [totalTests, maybeTotalAssertions]);
|
}, [totalTests, numAssertions]);
|
||||||
|
|
||||||
// Pre-sort the list of assertions based on which has been most recently executed.
|
// Pre-sort the list of assertions based on which has been most recently executed.
|
||||||
assertions.sort(sortAssertions);
|
assertions.sort(sortAssertions);
|
||||||
@ -77,13 +80,9 @@ export const ValidationsTab = () => {
|
|||||||
<>
|
<>
|
||||||
<TabToolbar>
|
<TabToolbar>
|
||||||
<div>
|
<div>
|
||||||
<Button
|
<Button type="text" disabled={numAssertions === 0} onClick={() => setView(ViewType.ASSERTIONS)}>
|
||||||
type="text"
|
|
||||||
disabled={effectiveTotalAssertions === 0}
|
|
||||||
onClick={() => setView(ViewType.ASSERTIONS)}
|
|
||||||
>
|
|
||||||
<FileProtectOutlined />
|
<FileProtectOutlined />
|
||||||
Assertions ({effectiveTotalAssertions})
|
Assertions ({numAssertions})
|
||||||
</Button>
|
</Button>
|
||||||
<Button type="text" disabled={totalTests === 0} onClick={() => setView(ViewType.TESTS)}>
|
<Button type="text" disabled={totalTests === 0} onClick={() => setView(ViewType.TESTS)}>
|
||||||
<FileDoneOutlined />
|
<FileDoneOutlined />
|
||||||
|
|||||||
@ -198,22 +198,34 @@ fragment viewProperties on Dataset {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fragment assertionsQuery on Dataset {
|
||||||
|
assertions(start: 0, count: 100) {
|
||||||
|
start
|
||||||
|
count
|
||||||
|
total
|
||||||
|
assertions {
|
||||||
|
...assertionDetails
|
||||||
|
runEvents(status: COMPLETE, limit: 1) {
|
||||||
|
total
|
||||||
|
failed
|
||||||
|
succeeded
|
||||||
|
runEvents {
|
||||||
|
...assertionRunEventDetails
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
query getDatasetAssertions($urn: String!) {
|
query getDatasetAssertions($urn: String!) {
|
||||||
dataset(urn: $urn) {
|
dataset(urn: $urn) {
|
||||||
assertions(start: 0, count: 100) {
|
...assertionsQuery
|
||||||
start
|
siblings {
|
||||||
count
|
isPrimary
|
||||||
total
|
siblings {
|
||||||
assertions {
|
urn
|
||||||
...assertionDetails
|
type
|
||||||
runEvents(status: COMPLETE, limit: 1) {
|
...assertionsQuery
|
||||||
total
|
|
||||||
failed
|
|
||||||
succeeded
|
|
||||||
runEvents {
|
|
||||||
...assertionRunEventDetails
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user