Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrczarnas committed Jan 23, 2024
2 parents 6ab5b88 + 201ce37 commit 730b05a
Showing 1 changed file with 74 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,67 +86,6 @@ export const EditProfilingReferenceTable = ({
...obj
}));
};
const checkIfRowAndColumnCountClicked = () => {
let values: string | any[] = [];
if (!checksUI) {
return;
}
values = Object.values(checksUI);

if (values.length === 0 || !Array.isArray(values[0])) {
return;
}
const comparisonCategory = values[0].find(
(x) => x && x.category === `comparisons/${selectedReference}`
);
if (!comparisonCategory || !comparisonCategory.checks) {
return;
}

const rowCountElem = comparisonCategory.checks.find((c: any) =>
c.check_name.includes('row_count_match')
);

const columnCountElem = comparisonCategory.checks.find((c: any) =>
c.check_name.includes('column_count_match')
);

if (rowCountElem) {
setShowRowCount(!!rowCountElem.configured);
}
if (columnCountElem) {
setShowColumnCount(!!columnCountElem.configured);
}
if (rowCountElem?.configured === true) {
onChange({
compare_row_count: {
warning_difference_percent:
rowCountElem.rule.warning.rule_parameters[0].double_value,
error_difference_percent:
rowCountElem.rule.error.rule_parameters[0].double_value,
fatal_difference_percent:
rowCountElem.rule.fatal.rule_parameters[0].double_value
}
});
} else {
onChange({ compare_row_count: reference?.default_compare_thresholds });
}
if (columnCountElem?.configured === true) {
onChange({
compare_column_count: {
warning_difference_percent:
columnCountElem.rule.warning.rule_parameters[0].double_value,
error_difference_percent:
columnCountElem.rule.error.rule_parameters[0].double_value,
fatal_difference_percent:
columnCountElem.rule.fatal.rule_parameters[0].double_value
}
});
} else {
onChange({ compare_column_count: reference?.default_compare_thresholds });
}
//cCompareThreshholdsModel in java fatal returns null
};

const handleChange = async (value: CheckContainerModel) => {
return new Promise<void>((resolve) => {
Expand Down Expand Up @@ -268,10 +207,77 @@ export const EditProfilingReferenceTable = ({
).then(callback);
}
}
checkIfRowAndColumnCountClicked();
}
}, [selectedReference]);

useEffect(() => {
const checkIfRowAndColumnCountClicked = () => {
let values: string | any[] = [];
if (!checksUI) {
return;
}
values = Object.values(checksUI);

if (values.length === 0 || !Array.isArray(values[0])) {
return;
}
const comparisonCategory = values[0].find(
(x) => x && x.category === `comparisons/${selectedReference}`
);
if (!comparisonCategory || !comparisonCategory.checks) {
return;
}

const rowCountElem = comparisonCategory.checks.find((c: any) =>
c.check_name.includes('row_count_match')
);

const columnCountElem = comparisonCategory.checks.find((c: any) =>
c.check_name.includes('column_count_match')
);

if (rowCountElem) {
setShowRowCount(!!rowCountElem.configured);
}
if (columnCountElem) {
setShowColumnCount(!!columnCountElem.configured);
}
if (rowCountElem?.configured === true) {
onChange({
compare_row_count: {
warning_difference_percent:
rowCountElem.rule.warning.rule_parameters[0].double_value,
error_difference_percent:
rowCountElem.rule.error.rule_parameters[0].double_value,
fatal_difference_percent:
rowCountElem.rule.fatal.rule_parameters[0].double_value
}
});
} else {
onChange({ compare_row_count: reference?.default_compare_thresholds });
}
if (columnCountElem?.configured === true) {
onChange({
compare_column_count: {
warning_difference_percent:
columnCountElem.rule.warning.rule_parameters[0].double_value,
error_difference_percent:
columnCountElem.rule.error.rule_parameters[0].double_value,
fatal_difference_percent:
columnCountElem.rule.fatal.rule_parameters[0].double_value
}
});
} else {
onChange({
compare_column_count: reference?.default_compare_thresholds
});
}
//cCompareThreshholdsModel in java fatal returns null
};

checkIfRowAndColumnCountClicked();
}, [selectedReference, checksUI]);

const onChange = (obj: Partial<TableComparisonModel>): void => {
setReference({
...(reference || {}),
Expand Down Expand Up @@ -609,7 +615,9 @@ export const EditProfilingReferenceTable = ({
checksUI={checksUI}
type="row"
/>
) : <div className='h-39'></div>}
) : (
<div className="h-39"></div>
)}
{rowKey ? (
<TableLevelResults
tableComparisonResults={tableComparisonResults}
Expand All @@ -631,7 +639,9 @@ export const EditProfilingReferenceTable = ({
checksUI={checksUI}
type="column"
/>
) : <div className='h-39'></div>}
) : (
<div className="h-39"></div>
)}
{columnKey ? (
<TableLevelResults
tableComparisonResults={tableComparisonResults}
Expand Down

0 comments on commit 730b05a

Please sign in to comment.