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