fix: use config PriceHistoryDays

This commit is contained in:
Derrick Hammer 2024-03-10 13:56:41 -04:00
parent effb341418
commit e425c038e1
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 3 additions and 3 deletions

View File

@ -74,7 +74,7 @@ func (p PriceTracker) recordRate() {
func (p PriceTracker) updatePrices() error { func (p PriceTracker) updatePrices() error {
var averageRate float64 var averageRate float64
x := 1 days := p.config.Config().Core.Storage.Sia.PriceHistoryDays
sql := ` sql := `
SELECT AVG(rate) as average_rate FROM ( SELECT AVG(rate) as average_rate FROM (
SELECT rate FROM ( SELECT rate FROM (
@ -84,9 +84,9 @@ SELECT AVG(rate) as average_rate FROM (
) tmp WHERE rn = 1 ) tmp WHERE rn = 1
) final; ) final;
` `
err := p.db.Raw(sql, x).Scan(&averageRate).Error err := p.db.Raw(sql, days).Scan(&averageRate).Error
if err != nil { if err != nil {
p.logger.Error("failed to fetch average rate", zap.Error(err), zap.Int("days", x)) p.logger.Error("failed to fetch average rate", zap.Error(err), zap.Uint64("days", days))
return err return err
} }