Remame db.Metric.Value to db.Metric.Type
This commit is contained in:
parent
e83cf56126
commit
282339e7af
|
@ -1,8 +1,8 @@
|
|||
package db
|
||||
|
||||
const (
|
||||
METRIC_VALUE_NONE = 0 + iota
|
||||
METRIC_VALUE_GRAM
|
||||
METRIC_VALUE_KILOGRAM
|
||||
METRIC_VALUE_LITER
|
||||
METRIC_TYPE_NONE = 0 + iota
|
||||
METRIC_TYPE_GRAM
|
||||
METRIC_TYPE_KILOGRAM
|
||||
METRIC_TYPE_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 {
|
||||
metricsThatNeeded := []*Metric{
|
||||
&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},
|
||||
&Metric{Name: "None", Short: "pcs", Type: METRIC_TYPE_NONE},
|
||||
&Metric{Name: "Gram", Short: "g", Type: METRIC_TYPE_GRAM},
|
||||
&Metric{Name: "Kilogram", Short: "kg", Type: METRIC_TYPE_KILOGRAM},
|
||||
&Metric{Name: "Liter", Short: "l", Type: METRIC_TYPE_LITER},
|
||||
}
|
||||
return checkSeededValues(metricsThatNeeded, CANT_FIND_METRIC, tx)
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import "gorm.io/gorm"
|
|||
|
||||
type Metric struct {
|
||||
gorm.Model
|
||||
Value uint8
|
||||
Type uint8
|
||||
Name string
|
||||
Short string
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import (
|
|||
|
||||
var metricTransform func(inp *db.Metric) types.DbMetric = func(inp *db.Metric) types.DbMetric {
|
||||
return types.DbMetric{
|
||||
Value: inp.Value,
|
||||
Type: inp.Type,
|
||||
Name: inp.Name,
|
||||
Short: inp.Short,
|
||||
}
|
||||
|
|
|
@ -143,7 +143,7 @@ type DbItemSearch struct {
|
|||
}
|
||||
|
||||
type DbMetric struct {
|
||||
Value uint8 `json:"value" example:"1"`
|
||||
Type uint8 `json:"type" example:"1"`
|
||||
Name string `json:"name" example:"Kilogram"`
|
||||
Short string `json:"short" example:"kg"`
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user