fix(data): 清理旧数据并保护服务端写入
This commit is contained in:
@@ -58,6 +58,29 @@ export function buildRequirementScopeTree(
|
||||
});
|
||||
}
|
||||
|
||||
export function filterRequirementScopeTreeByKeyword(
|
||||
tree: RequirementProductScopeNode[],
|
||||
keyword: string,
|
||||
): RequirementProductScopeNode[] {
|
||||
const query = normalizeScopeKeyword(keyword);
|
||||
if (!query) return tree;
|
||||
|
||||
const filtered: RequirementProductScopeNode[] = [];
|
||||
for (const product of tree) {
|
||||
if (normalizeScopeKeyword(product.name).includes(query)) {
|
||||
filtered.push(product);
|
||||
continue;
|
||||
}
|
||||
|
||||
const projects = product.projects.filter((project) => normalizeScopeKeyword(project.name).includes(query));
|
||||
if (projects.length > 0) {
|
||||
filtered.push({ ...product, projects });
|
||||
}
|
||||
}
|
||||
|
||||
return filtered;
|
||||
}
|
||||
|
||||
function countRequirements(requirements: Requirement[]): RequirementScopeCount {
|
||||
const byStatus: Partial<Record<RequirementStatus, number>> = {};
|
||||
for (const requirement of requirements) {
|
||||
@@ -68,3 +91,7 @@ function countRequirements(requirements: Requirement[]): RequirementScopeCount {
|
||||
byStatus,
|
||||
};
|
||||
}
|
||||
|
||||
function normalizeScopeKeyword(value: string): string {
|
||||
return value.trim().toLowerCase();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user