diff --git a/db/consts.go b/db/consts.go new file mode 100644 index 0000000..9fa9642 --- /dev/null +++ b/db/consts.go @@ -0,0 +1,8 @@ +package db + +const ( + METRIC_VALUE_NONE = 0 + iota + METRIC_VALUE_GRAM + METRIC_VALUE_KILOGRAM + METRIC_VALUE_LITER +) diff --git a/db/db.go b/db/db.go index 1ae82fe..c37a493 100644 --- a/db/db.go +++ b/db/db.go @@ -107,10 +107,10 @@ func checkSeededValues[T Identifiable](whatToCheck []*T, errorIfNotFound error, func initMetrics(tx *gorm.DB) error { metricsThatNeeded := []*Metric{ - &Metric{Name: "None", Short: "pcs", Value: 0}, - &Metric{Name: "Gram", Short: "g", Value: 1}, - &Metric{Name: "Kilogram", Short: "kg", Value: 2}, - &Metric{Name: "Liter", Short: "l", Value: 3}, + &Metric{Name: "None", Short: "pcs", Value: METRIC_VALUE_NONE}, + &Metric{Name: "Gram", Short: "g", Value: METRIC_VALUE_GRAM}, + &Metric{Name: "Kilogram", Short: "kg", Value: METRIC_VALUE_KILOGRAM}, + &Metric{Name: "Liter", Short: "l", Value: METRIC_VALUE_LITER}, } return checkSeededValues(metricsThatNeeded, CANT_FIND_METRIC, tx) }