perf(web): 优化大数据量页面切换与聚合性能
This commit is contained in:
@@ -28,6 +28,31 @@ export function deriveReqDevStatus(reqId: string, devTasks: DevTask[]): ReqDevSt
|
||||
return 'todo';
|
||||
}
|
||||
|
||||
export function buildRequirementDevStatusMap(devTasks: DevTask[]): Map<string, ReqDevStatus> {
|
||||
const stats = new Map<string, { total: number; submitted: number; active: boolean }>();
|
||||
|
||||
for (const task of devTasks) {
|
||||
if (!task.requirementId) continue;
|
||||
const row = stats.get(task.requirementId) ?? { total: 0, submitted: 0, active: false };
|
||||
row.total += 1;
|
||||
if (task.status === 'submitted') row.submitted += 1;
|
||||
if (task.status === 'in_progress' || task.status === 'testing') row.active = true;
|
||||
stats.set(task.requirementId, row);
|
||||
}
|
||||
|
||||
const statusMap = new Map<string, ReqDevStatus>();
|
||||
for (const [requirementId, row] of stats) {
|
||||
if (row.total > 0 && row.submitted === row.total) {
|
||||
statusMap.set(requirementId, 'completed');
|
||||
} else if (row.active) {
|
||||
statusMap.set(requirementId, 'developing');
|
||||
} else {
|
||||
statusMap.set(requirementId, 'todo');
|
||||
}
|
||||
}
|
||||
return statusMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 需求是否可编辑
|
||||
* 规则:开发中(有 in_progress 或 testing 的任务)不可编辑
|
||||
|
||||
Reference in New Issue
Block a user