fix: manday count
This commit is contained in:
@ -668,6 +668,31 @@ function renderHTML(nodes, isRoot) {
|
||||
return html;
|
||||
}
|
||||
|
||||
function calculateNodeManday(node, coveredByParentWithManday) {
|
||||
let manday = 0;
|
||||
let hasManday = false;
|
||||
if (node.manday) {
|
||||
let val = parseFloat(node.manday);
|
||||
if (!isNaN(val) && val > 0) {
|
||||
// Rule: Divide by number of leaders
|
||||
let divisor = (node.leaders && node.leaders.length > 0) ? node.leaders.length : 1;
|
||||
manday = val / divisor;
|
||||
hasManday = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (node.isMatch) {
|
||||
if (coveredByParentWithManday) return 0; // Already counted at a higher level
|
||||
if (hasManday) return manday; // This node matches and has its own manday, use it and ignore descendants' manday
|
||||
// Match but no manday on this node, accumulate from matching descendants
|
||||
return node.children.reduce((acc, child) => acc + calculateNodeManday(child, false), 0);
|
||||
} else {
|
||||
// This node doesn't match, check descendants.
|
||||
// If a parent match already covered this branch, we still pass that info down.
|
||||
return node.children.reduce((acc, child) => acc + calculateNodeManday(child, coveredByParentWithManday), 0);
|
||||
}
|
||||
}
|
||||
|
||||
function countNodes(nodes) {
|
||||
return nodes.reduce((sum, n) => sum + 1 + countNodes(n.children), 0);
|
||||
}
|
||||
@ -685,16 +710,12 @@ function generateSummary(nodes, status, leader) {
|
||||
let matched = collectMatchedNodes(nodes);
|
||||
if (matched.length === 0) return '';
|
||||
|
||||
let totalMandays = 0;
|
||||
let totalMandays = nodes.reduce((sum, n) => sum + calculateNodeManday(n, false), 0);
|
||||
let completed = 0;
|
||||
let ongoing = 0;
|
||||
let taskNames = [];
|
||||
|
||||
matched.forEach(r => {
|
||||
if (r.manday) {
|
||||
let num = parseFloat(r.manday);
|
||||
if (!isNaN(num)) totalMandays += num;
|
||||
}
|
||||
if (r.status && (r.status.includes('Completed') || r.status.includes('完成'))) completed++;
|
||||
else if (r.status && (r.status.includes('Ongoing') || r.status.includes('进行中'))) ongoing++;
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user