Zero aggregations should have the previous price
This commit is contained in:
parent
2abed9d9ed
commit
31fd8deed9
@ -144,7 +144,7 @@ func (a *AggregationValidator) emitZero() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *AggregationValidator) checkZero(product string, interval time.Duration) {
|
func (a *AggregationValidator) checkZero(product string, interval time.Duration) {
|
||||||
a.Logger.Info("aggregation validator: START missing aggregations. " +
|
a.Logger.Info("aggregation validator: START missing aggregations. "+
|
||||||
"product: %v. interval: %v", product, interval)
|
"product: %v. interval: %v", product, interval)
|
||||||
|
|
||||||
missing, err := a.Database.AggregationService().MissingTimes(int(interval.Seconds()),
|
missing, err := a.Database.AggregationService().MissingTimes(int(interval.Seconds()),
|
||||||
@ -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)
|
||||||
}
|
}
|
||||||
|
|
||||||
a.Logger.Info("aggregation validator: DONE missing aggregations. " +
|
missing.Close()
|
||||||
|
|
||||||
|
a.Logger.Info("aggregation validator: DONE missing aggregations. "+
|
||||||
"product: %v. interval: %v", product, interval)
|
"product: %v. interval: %v", product, interval)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user