package domain import ( "fmt" "math" ) // ComputeTrendFromAvgs is a pure version of the trend computation for testing. func ComputeTrendFromAvgs(recentAvg, olderAvg float64) (pts int, direction string) { if olderAvg < 1 { if recentAvg > 0 { return 15, "new" } return 5, "stable" } changePct := math.Round((recentAvg - olderAvg) / olderAvg * 100) if recentAvg > olderAvg*1.2 { return 15, fmt.Sprintf("+%.0f%%", changePct) } if olderAvg > recentAvg*1.2 { return 0, fmt.Sprintf("%.0f%%", changePct) } return 5, "stable" }