Add CANT_FIND_CURRENCY error to db.go and fix problem when initCurrencies returned CANT_FIND_METRIC

This commit is contained in:
qowevisa 2024-12-01 13:22:41 +02:00
parent 282339e7af
commit 2566ec8eaa

View File

@ -78,6 +78,7 @@ func Connect() *gorm.DB {
var ( var (
CANT_FIND_METRIC = errors.New("Can't find proper metrics in database") CANT_FIND_METRIC = errors.New("Can't find proper metrics in database")
CANT_FIND_CURRENCY = errors.New("Can't find proper currencies in database")
) )
func checkSeededValues[T Identifiable](whatToCheck []*T, errorIfNotFound error, tx *gorm.DB) error { func checkSeededValues[T Identifiable](whatToCheck []*T, errorIfNotFound error, tx *gorm.DB) error {
@ -127,7 +128,7 @@ func initCurrencies(tx *gorm.DB) error {
{Name: "Kazakhstani Tenge", Symbol: "₸", ISOName: "KZT"}, {Name: "Kazakhstani Tenge", Symbol: "₸", ISOName: "KZT"},
{Name: "Chinese Yuan", Symbol: "¥", ISOName: "CNY"}, {Name: "Chinese Yuan", Symbol: "¥", ISOName: "CNY"},
} }
return checkSeededValues(currsThatNeeded, CANT_FIND_METRIC, tx) return checkSeededValues(currsThatNeeded, CANT_FIND_CURRENCY, tx)
} }
func initStateOfDb(tx *gorm.DB) error { func initStateOfDb(tx *gorm.DB) error {