inflation implementation
All checks were successful
release-tag / release-image (push) Successful in 15m32s
build / build (push) Successful in 42s

This commit is contained in:
Tijl 2024-09-08 01:31:07 +02:00
parent c944e84771
commit 9ada121417
Signed by: tijl
GPG Key ID: DAE24BFCD722F053
2 changed files with 13 additions and 6 deletions

View File

@ -26,16 +26,14 @@ type Datas struct {
var rawData = make(map[string]map[time.Time]float32)
var datas = map[string]Datas{
/*
"FPCPITOTLZGUSA": {
Name: "CPI USA",
ProcessFunction: func(m map[time.Time]float32) map[time.Time]float32 { return m },
},
*/
"CPIAUCSL": {
Name: "CPI USA BASE",
ProcessFunction: toPercent,
},
"PCEPI": {
Name: "PCECPI USA",
ProcessFunction: toPercent,
},
"M2SL": {
Name: "M2 USA",
ProcessFunction: toPercent,
@ -44,6 +42,10 @@ var datas = map[string]Datas{
Name: "HICP ECB",
ProcessFunction: toPercent,
},
"MABMM301EZM189S": {
Name: "M3 ECB",
ProcessFunction: toPercent,
},
}
//go:embed locales/*
@ -139,6 +141,7 @@ func LoadData() error {
}
resp, err := http.Get(fredBaseUrl + id)
log.Debug().Str("id", id).Msg("inflation.LoadData: getting")
if err != nil {
return err
}

View File

@ -96,6 +96,10 @@ func readCSV(filePath string) (map[time.Time]float32, error) {
continue
}
if len(record) < 2 || record[1] == "." {
continue
}
date, err := time.Parse("2006-01-02", record[0])
if err != nil {
return nil, fmt.Errorf("error parsing date on line %d: %v", i+1, err)