Skip to content

Commit

Permalink
Merged PR 2937: 12920 setting values correctly
Browse files Browse the repository at this point in the history
setting values correctly
  • Loading branch information
Aleksy Lisowski authored and piotrczarnas committed Aug 20, 2024
2 parents af2ee78 + e6e596f commit 127feb2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ const RuleMiningChecksContainer = ({
);
const [mode, setMode] = useState<string>();
const [copyUI, setCopyUI] = useState<CheckContainerModel>();
const [showAdvanced, setShowAdvanced] = useState<boolean>(
isFiltered === true
);
const [isExtendedArray, setIsExtendedArray] = useState<string[]>([
'Table level checks'
]);
Expand All @@ -79,21 +76,20 @@ const RuleMiningChecksContainer = ({

const handleChangeTableDataGrouping = (
check: CheckModel,
idx: number,
jdx: number
categoryName: string
) => {
if (!checksUI) return;
const newChecksUI = {
...checksUI,
table_checks: {
...checksUI.table_checks,
categories: checksUI.table_checks?.categories?.map((category, index) =>
index !== idx
categories: checksUI.table_checks?.categories?.map((category) =>
category.category !== categoryName
? category
: {
...category,
checks: category?.checks?.map((item, jindex) =>
jindex !== jdx ? item : check
checks: category?.checks?.map((item) =>
check.check_name !== item.check_name ? item : check
)
}
)
Expand All @@ -103,25 +99,25 @@ const RuleMiningChecksContainer = ({
};
const handleChangeColumnDataGrouping = (
check: CheckModel,
idx: number,
jdx: number,
columnName: string
columnName: string,
categoryName: string
) => {
if (!checksUI) return;

const newChecksUI = {
...checksUI,
column_checks: {
...checksUI.column_checks,
[columnName]: {
...checksUI?.column_checks?.[columnName],
categories: checksUI.column_checks?.[columnName]?.categories?.map(
(category, index) =>
index !== idx
(category) =>
category.category !== categoryName
? category
: {
...category,
checks: category?.checks?.map((item, jindex) =>
jindex !== jdx ? item : check
checks: category?.checks?.map((item) =>
item.check_name !== check.check_name ? item : check
)
}
)
Expand All @@ -131,6 +127,7 @@ const RuleMiningChecksContainer = ({

onChange(newChecksUI);
};

const changeCopyUI = (
category: string,
checkName: string,
Expand Down Expand Up @@ -229,8 +226,8 @@ const RuleMiningChecksContainer = ({
<RuleMiningChecksContainerCategory
category={category}
timeWindowFilter={RUN_CHECK_TIME_WINDOW_FILTERS[timeWindow]}
handleChangeDataGroupingConfiguration={(check, jIndex) =>
handleChangeTableDataGrouping(check, index, jIndex)
handleChangeColumnDataGroupingConfiguration={(check) =>
handleChangeTableDataGrouping(check, category.category ?? '')
}
onUpdate={onUpdate}
mode={mode}
Expand All @@ -239,7 +236,7 @@ const RuleMiningChecksContainer = ({
(item) => item.category === category.category
)}
isDefaultEditing={isDefaultEditing}
showAdvanced={showAdvanced}
showAdvanced={true}
isFiltered={isFiltered}
ruleParamenterConfigured={ruleParametersConfigured}
onChangeRuleParametersConfigured={
Expand Down Expand Up @@ -285,8 +282,12 @@ const RuleMiningChecksContainer = ({
key={x.category && x?.category + jindex}
category={x}
timeWindowFilter={RUN_CHECK_TIME_WINDOW_FILTERS[timeWindow]}
handleChangeDataGroupingConfiguration={(check, jIndex) =>
handleChangeColumnDataGrouping(check, index, jIndex, key)
handleChangeColumnDataGroupingConfiguration={(check) =>
handleChangeColumnDataGrouping(
check,
key,
x.category ?? ''
)
}
onUpdate={onUpdate}
mode={mode}
Expand All @@ -295,7 +296,7 @@ const RuleMiningChecksContainer = ({
(item) => item.category === category
)}
isDefaultEditing={isDefaultEditing}
showAdvanced={showAdvanced}
showAdvanced={true}
isFiltered={isFiltered}
ruleParamenterConfigured={ruleParametersConfigured}
onChangeRuleParametersConfigured={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,8 @@ import {
QualityCategoryModel,
TimeWindowFilterParameters
} from '../../api';
import { useActionDispatch } from '../../hooks/useActionDispatch';
import { setCurrentJobId } from '../../redux/actions/source.actions';
import { IRootState } from '../../redux/reducers';
import { getFirstLevelActiveTab } from '../../redux/selectors';
import { JobApiClient } from '../../services/apiClient';
import { CheckTypes } from '../../shared/routes';
import { useDecodedParams } from '../../utils';
import DeleteOnlyDataDialog from '../CustomTree/DeleteOnlyDataDialog';
import SvgIcon from '../SvgIcon';
import RuleMiningChecksContainerListItem from './RuleMiningChecksContainerListItem';
Expand All @@ -20,11 +15,7 @@ type CheckIndexTuple = [check: CheckModel, index: number];

interface CheckCategoriesViewProps {
category: QualityCategoryModel;
handleChangeDataGroupingConfiguration: (
check: CheckModel,
index: number,
columnName?: string
) => void;
handleChangeColumnDataGroupingConfiguration: (check: CheckModel) => void;
onUpdate: () => void;
timeWindowFilter?: TimeWindowFilterParameters | null;
mode?: string;
Expand All @@ -40,7 +31,7 @@ interface CheckCategoriesViewProps {
const RuleMiningChecksContainerCategory = ({
mode,
category,
handleChangeDataGroupingConfiguration,
handleChangeColumnDataGroupingConfiguration,
onUpdate,
timeWindowFilter,
changeCopyUI,
Expand All @@ -53,9 +44,6 @@ const RuleMiningChecksContainerCategory = ({
onChangeRuleParametersConfigured
}: CheckCategoriesViewProps) => {
const [deleteDataDialogOpened, setDeleteDataDialogOpened] = useState(false);
const { checkTypes }: { checkTypes: CheckTypes } = useDecodedParams();
const dispatch = useActionDispatch();
const firstLevelActiveTab = useSelector(getFirstLevelActiveTab(checkTypes));
const [isExtended, setIsExtended] = useState(false);

const { userProfile } = useSelector((state: IRootState) => state.job || {});
Expand All @@ -70,26 +58,6 @@ const RuleMiningChecksContainerCategory = ({
}
};

const onRunChecks = async () => {
await onUpdate();
const res = await JobApiClient.runChecks(undefined, false, undefined, {
check_search_filters: category?.run_checks_job_template,
...(checkTypes === CheckTypes.PARTITIONED && timeWindowFilter !== null
? {
time_window_filter: timeWindowFilter,
collect_error_samples: true
}
: { collect_error_samples: true })
});
dispatch(
setCurrentJobId(
checkTypes,
firstLevelActiveTab,
res.data?.jobId?.jobId ?? 0
)
);
};

useEffect(() => {
shouldExtend();
}, []);
Expand Down Expand Up @@ -147,7 +115,7 @@ const RuleMiningChecksContainerCategory = ({
check={tuple[0]}
key={tuple[1]}
onChange={(item) =>
handleChangeDataGroupingConfiguration(item, tuple[1])
handleChangeColumnDataGroupingConfiguration(item)
}
onUpdate={onUpdate}
timeWindowFilter={timeWindowFilter}
Expand Down

0 comments on commit 127feb2

Please sign in to comment.