Zero aggregations should have the previous price

This commit is contained in:
Kevin Cotugno 2017-10-17 22:12:15 -07:00
parent 2abed9d9ed
commit 31fd8deed9

View File

@ -154,15 +154,29 @@ func (a *AggregationValidator) checkZero(product string, interval time.Duration)
return return
} }
var i int
for missing.Next() { for missing.Next() {
i++
agg := missing.Value().(tacitus.Aggregation) agg := missing.Value().(tacitus.Aggregation)
agg.Interval = int(interval.Seconds()) agg.Interval = int(interval.Seconds())
last := agg.Timestamp.Add(-interval)
previous, err := a.Database.AggregationService().
Aggregation(int(interval.Seconds()), product, last)
if err != nil {
a.Logger.Info("aggregation validator: FAIL missing aggregations. "+
"product: %v. interval: %v", product, interval)
missing.Close()
return
}
agg.Price = previous.Price
a.Database.AggregationService().CreateAggregation(agg) a.Database.AggregationService().CreateAggregation(agg)
} }
missing.Close()
a.Logger.Info("aggregation validator: DONE missing aggregations. "+ a.Logger.Info("aggregation validator: DONE missing aggregations. "+
"product: %v. interval: %v", product, interval) "product: %v. interval: %v", product, interval)
} }