WAY faster doing cumulative balances over summing [0,i] every reg loop
All checks were successful
cicd / ci (push) Successful in 1m39s

This commit is contained in:
bel
2025-04-06 10:05:42 -06:00
parent 058874b566
commit 9352ca82de

View File

@@ -107,8 +107,8 @@ func Main() {
FPrintBalances(w, "", balances, nil, config.Query.USDOnly, config.Query.Normalize, time.Now().Format("2006-01-02"))
case "reg":
transactions := deltas.Transactions()
for i, transaction := range transactions {
cumulative := make(ledger.Balances)
for _, transaction := range transactions {
balances := ledger.Deltas(transaction).Like(q).Group(group).Balances().WithBPIsAt(bpis, transaction[0].Date).Nonzero()
shouldPrint := false
shouldPrint = shouldPrint || len(balances) > 2
@@ -121,8 +121,10 @@ func Main() {
shouldPrint = shouldPrint || len(balances) > 0
}
if shouldPrint {
cumulative.PushAll(balances)
cumulative = cumulative.Nonzero()
fmt.Fprintf(w, "%s\t%s\n", transaction[0].Date, transaction[0].Description)
FPrintBalances(w, "\t\t", balances, transactions[:i+1].Deltas().Like(q).Group(group).Balances().WithBPIsAt(bpis, transaction[0].Date).Nonzero(), config.Query.USDOnly, config.Query.Normalize, transaction[0].Date)
FPrintBalances(w, "\t\t", balances, cumulative, config.Query.USDOnly, config.Query.Normalize, transaction[0].Date)
}
}
default: