-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreporter.js
More file actions
37 lines (35 loc) · 1.97 KB
/
Copy pathreporter.js
File metadata and controls
37 lines (35 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
const ICON = { critical: 'CRITICAL', moderate: 'MODERATE', healthy: 'HEALTHY' };
function generateReport(processName, scoredSteps) {
const critical = scoredSteps.filter(s => s.severity === 'critical');
const moderate = scoredSteps.filter(s => s.severity === 'moderate');
const totalMins = scoredSteps.reduce((a, s) => a + s.avg_duration_mins, 0);
const critMins = critical.reduce((a, s) => a + s.avg_duration_mins, 0);
const delayShare = totalMins > 0 ? Math.round((critMins / totalMins) * 100) : 0;
const lines = [
`# Process Analysis Report: ${processName}`,
`*Generated: ${new Date().toLocaleDateString('en-GB', { dateStyle: 'long' })}*`,
'', '---', '',
'## Executive Summary', '',
`**${critical.length}** of **${scoredSteps.length}** steps are critical bottlenecks, ` +
`accounting for ~**${delayShare}%** of total process duration.`,
`**${moderate.length}** steps are moderate concerns.`,
'', '---', '',
'## Step Analysis', '',
'| # | Step | Owner | Dur (min) | Error % | Handoffs | Auto % | BI | Status |',
'|---|------|-------|-----------|---------|----------|--------|----|--------|',
...scoredSteps.map((s, i) =>
`| ${i+1} | ${s.name} | ${s.owner} | ${s.avg_duration_mins} | ${s.error_rate_pct} | ${s.handoffs} | ${s.automation_pct} | **${s.bottleneck_index}** | ${ICON[s.severity]} |`
),
'', '---', '', '## Priority Action Plan', '',
...critical.flatMap((s, i) => [
`### ${i+1}. ${s.name} (BI: ${s.bottleneck_index})`,
`- **Owner**: ${s.owner}`,
`- **Signals**: ${s.error_rate_pct}% error rate, ${s.handoffs} handoffs, ${s.avg_duration_mins} min avg`,
`- **Recommended**: Audit manual steps; target automation lift from ${s.automation_pct}% → 60%+; reduce handoffs`, '',
]),
'---', '', '## BI Formula',
'```', 'BI = 0.35×NormDuration + 0.30×NormErrorRate + 0.20×NormHandoffs + 0.15×(1−NormAutomation)', '```',
];
return lines.join('\n');
}
module.exports = { generateReport };