Add consts.go to db package and move all Metric values to consts.go
This commit is contained in:
parent
eeaec565bd
commit
e83cf56126
8
db/consts.go
Normal file
8
db/consts.go
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
package db
|
||||||
|
|
||||||
|
const (
|
||||||
|
METRIC_VALUE_NONE = 0 + iota
|
||||||
|
METRIC_VALUE_GRAM
|
||||||
|
METRIC_VALUE_KILOGRAM
|
||||||
|
METRIC_VALUE_LITER
|
||||||
|
)
|
8
db/db.go
8
db/db.go
|
@ -107,10 +107,10 @@ func checkSeededValues[T Identifiable](whatToCheck []*T, errorIfNotFound error,
|
||||||
|
|
||||||
func initMetrics(tx *gorm.DB) error {
|
func initMetrics(tx *gorm.DB) error {
|
||||||
metricsThatNeeded := []*Metric{
|
metricsThatNeeded := []*Metric{
|
||||||
&Metric{Name: "None", Short: "pcs", Value: 0},
|
&Metric{Name: "None", Short: "pcs", Value: METRIC_VALUE_NONE},
|
||||||
&Metric{Name: "Gram", Short: "g", Value: 1},
|
&Metric{Name: "Gram", Short: "g", Value: METRIC_VALUE_GRAM},
|
||||||
&Metric{Name: "Kilogram", Short: "kg", Value: 2},
|
&Metric{Name: "Kilogram", Short: "kg", Value: METRIC_VALUE_KILOGRAM},
|
||||||
&Metric{Name: "Liter", Short: "l", Value: 3},
|
&Metric{Name: "Liter", Short: "l", Value: METRIC_VALUE_LITER},
|
||||||
}
|
}
|
||||||
return checkSeededValues(metricsThatNeeded, CANT_FIND_METRIC, tx)
|
return checkSeededValues(metricsThatNeeded, CANT_FIND_METRIC, tx)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user