Skip to content

Commit 2554eda

Browse files
committed
add preventable loss
1 parent b6a1eef commit 2554eda

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

cmd/prcost/repository.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,12 @@ func printExtrapolatedResults(title string, days int, ext *cost.ExtrapolatedBrea
378378
fmt.Println()
379379
}
380380

381+
// Average Preventable Loss Total (before grand total)
382+
avgPreventableCost := avgCodeChurnCost + avgDeliveryDelayCost + avgCoordinationCost
383+
avgPreventableHours := avgCodeChurnHours + avgDeliveryDelayHours + avgCoordinationHours
384+
fmt.Printf(" Preventable Loss Total $%12s %s\n",
385+
formatWithCommas(avgPreventableCost), formatTimeUnit(avgPreventableHours))
386+
381387
// Average total
382388
fmt.Println(" ═══════════════════════════════════════════════════════════════")
383389
fmt.Printf(" Average Total $%12s %s\n",
@@ -481,6 +487,12 @@ func printExtrapolatedResults(title string, days int, ext *cost.ExtrapolatedBrea
481487
fmt.Println()
482488
}
483489

490+
// Preventable Loss Total (before grand total)
491+
preventableCost := ext.CodeChurnCost + ext.DeliveryDelayCost + ext.CoordinationCost
492+
preventableHours := ext.CodeChurnHours + ext.DeliveryDelayHours + ext.CoordinationHours
493+
fmt.Printf(" Preventable Loss Total $%12s %s\n",
494+
formatWithCommas(preventableCost), formatTimeUnit(preventableHours))
495+
484496
// Extrapolated grand total
485497
fmt.Println(" ═══════════════════════════════════════════════════════════════")
486498
fmt.Printf(" Total $%12s %s\n",

internal/server/static/index.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1531,6 +1531,11 @@ <h3>Why calculate PR costs?</h3>
15311531
output += ` Subtotal ${formatCurrency(avgFutureCost).padStart(12)} ${formatTimeUnit(avgFutureHours)} (${pct.toFixed(1)}%)\n\n`;
15321532
}
15331533

1534+
// Average Preventable Loss Total (before grand total)
1535+
const avgPreventableCost = avgCodeChurnCost + avgDeliveryDelayCost + avgCoordinationCost;
1536+
const avgPreventableHours = avgCodeChurnHours + avgDeliveryDelayHours + avgCoordinationHours;
1537+
output += ` Preventable Loss Total ${formatCurrency(avgPreventableCost).padStart(12)} ${formatTimeUnit(avgPreventableHours)}\n`;
1538+
15341539
// Average Total
15351540
output += ' ═══════════════════════════════════════════════════════════════\n';
15361541
output += ` Average Total ${formatCurrency(avgTotalCost).padStart(12)} ${formatTimeUnit(avgTotalHours)}\n\n`;
@@ -1598,6 +1603,11 @@ <h3>Why calculate PR costs?</h3>
15981603
output += ` Subtotal ${formatCurrency(futureCost).padStart(12)} ${formatTimeUnit(futureHours)} (${pct.toFixed(1)}%)\n\n`;
15991604
}
16001605

1606+
// Preventable Loss Total (before grand total)
1607+
const preventableCost = e.code_churn_cost + e.delivery_delay_cost + e.coordination_cost;
1608+
const preventableHours = e.code_churn_hours + e.delivery_delay_hours + e.coordination_hours;
1609+
output += ` Preventable Loss Total ${formatCurrency(preventableCost).padStart(12)} ${formatTimeUnit(preventableHours)}\n`;
1610+
16011611
// Total
16021612
output += ' ═══════════════════════════════════════════════════════════════\n';
16031613
output += ` Total ${formatCurrency(e.total_cost).padStart(12)} ${formatTimeUnit(e.total_hours)}\n\n`;

0 commit comments

Comments
 (0)