bpis predictFixedGrowth fixed
cicd / ci (push) Successful in 1m15s Details

main
Bel LaPointe 2025-06-16 18:12:11 -06:00
parent fe7c3a9682
commit 6aa549cb02
1 changed files with 5 additions and 8 deletions

View File

@ -297,6 +297,11 @@ func (router Router) APIReg(w http.ResponseWriter, r *http.Request) {
register := deltas.Register() register := deltas.Register()
predicted := make(ledger.Register) predicted := make(ledger.Register)
bpis, err := router.bpis()
if err != nil {
panic(err)
}
if predictionMonths, err := strconv.ParseInt(r.URL.Query().Get("predictionMonths"), 10, 16); err == nil && predictionMonths > 0 { if predictionMonths, err := strconv.ParseInt(r.URL.Query().Get("predictionMonths"), 10, 16); err == nil && predictionMonths > 0 {
window := time.Hour * 24.0 * 365.0 / 12.0 * time.Duration(predictionMonths) window := time.Hour * 24.0 * 365.0 / 12.0 * time.Duration(predictionMonths)
// TODO whatif // TODO whatif
@ -334,10 +339,6 @@ func (router Router) APIReg(w http.ResponseWriter, r *http.Request) {
if err != nil { if err != nil {
panic(err) panic(err)
} }
bpis, err := router.bpis()
if err != nil {
panic(err)
}
bpis, err = ana.BPIsWithFixedGrowthPrediction(bpis, window, currency, rate) bpis, err = ana.BPIsWithFixedGrowthPrediction(bpis, window, currency, rate)
if err != nil { if err != nil {
panic(err) panic(err)
@ -346,10 +347,6 @@ func (router Router) APIReg(w http.ResponseWriter, r *http.Request) {
} }
if r.URL.Query().Get("bpi") == "true" { if r.URL.Query().Get("bpi") == "true" {
bpis, err := router.bpis()
if err != nil {
panic(err)
}
register = register.WithBPIs(bpis) register = register.WithBPIs(bpis)
predicted = predicted.WithBPIs(bpis) predicted = predicted.WithBPIs(bpis)
} }