predict based on MAX DATE, not max value
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user