From 282339e7af487880c78f22eabea09364adf00eac Mon Sep 17 00:00:00 2001 From: qowevisa Date: Sun, 1 Dec 2024 13:16:44 +0200 Subject: [PATCH] Remame db.Metric.Value to db.Metric.Type --- db/consts.go | 8 ++++---- db/db.go | 8 ++++---- db/metric.go | 2 +- handlers/metric.go | 2 +- types/types.go | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/db/consts.go b/db/consts.go index 9fa9642..d74abff 100644 --- a/db/consts.go +++ b/db/consts.go @@ -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 ) diff --git a/db/db.go b/db/db.go index c37a493..9aedc9d 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: 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) } diff --git a/db/metric.go b/db/metric.go index daddf56..2d1edc8 100644 --- a/db/metric.go +++ b/db/metric.go @@ -4,7 +4,7 @@ import "gorm.io/gorm" type Metric struct { gorm.Model - Value uint8 + Type uint8 Name string Short string } diff --git a/handlers/metric.go b/handlers/metric.go index 1120389..533bd0b 100644 --- a/handlers/metric.go +++ b/handlers/metric.go @@ -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, } diff --git a/types/types.go b/types/types.go index f9e2c9b..3a560d7 100644 --- a/types/types.go +++ b/types/types.go @@ -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"` }