predict based on MAX DATE, not max value

This commit is contained in:
Bel LaPointe
2023-10-26 06:25:59 -06:00
parent c7423f8f72
commit a950c48ed1
2 changed files with 23 additions and 17 deletions

View File

@@ -48,6 +48,9 @@ func registerWithContributionPredictionForNameForCurrency(reg Register, window t
if err != nil {
return err
}
if time.Since(t) > time.Hour*24*180 {
continue
}
if v, ok := reg[d][name][currency]; ok {
contributions = append(contributions, contribution{t: t, v: v})
}
@@ -55,7 +58,7 @@ func registerWithContributionPredictionForNameForCurrency(reg Register, window t
sort.Slice(contributions, func(i, j int) bool {
return contributions[i].t.Before(contributions[j].t)
})
if len(contributions) < 2 {
if len(contributions) < 3 {
return nil
}
@@ -106,13 +109,11 @@ func registerWithContributionPredictionForNameForCurrency(reg Register, window t
}()
latest := func() float64 {
max := 0.0
for d := range reg {
if other := reg[d][name][currency]; other > max {
max = other
}
last := 0.0
for _, d := range reg.Dates() {
last = reg[d][name][currency]
}
return max
return last
}()
for _, predictionTime := range predictionTimes(window) {
k := predictionTime.Format("2006-01")