refactor: simplify findProcessGroupByPath function

This commit is contained in:
burnettk (aider) 2025-02-10 17:34:33 -05:00
parent 11ce256363
commit 236c6d70ac
No known key found for this signature in database

View File

@ -265,38 +265,19 @@ export default function ProcessModelTreePage({
const levels = path.split('/'); const levels = path.split('/');
let currentGroup: ProcessGroupLite | undefined; let currentGroup: ProcessGroupLite | undefined;
let assembledGroups = ''; let newGroups: ProcessGroupLite[] = [];
levels.forEach((level: string) => { if (groupsToProcess) {
if (assembledGroups === '') {
assembledGroups = level;
} else {
assembledGroups = `${assembledGroups}/${level}`;
}
let newGroups: ProcessGroupLite[] = [];
if (currentGroup && currentGroup.process_groups !== undefined) {
newGroups = currentGroup.process_groups;
} else if (groupsToProcess) {
newGroups = groupsToProcess; newGroups = groupsToProcess;
} }
if (!newGroups) { for (const level of levels) {
newGroups = []; const assembledPath = levels.slice(0, levels.indexOf(level) + 1).join('/');
} currentGroup = newGroups.find((processGroup: any) => processGroup.id === assembledPath);
if (newGroups === null) {
newGroups = [];
}
if (newGroups && Array.isArray(newGroups)) {
currentGroup = newGroups.find(
(processGroup: any) => processGroup.id === assembledGroups,
);
}
if (!currentGroup) { if (!currentGroup) {
return undefined; return undefined;
} }
return currentGroup; newGroups = currentGroup.process_groups || [];
}); }
return currentGroup; return currentGroup;
} }