parent
375193f9f4
commit
2373629a94
@ -1,12 +1,44 @@
|
|||||||
package services
|
package services
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type WeightLog struct {
|
var (
|
||||||
ID uint64 `json:"id"`
|
AllLogTypes = []LogType{
|
||||||
UserID uint64 `json:"userId"`
|
LogType("Weight"),
|
||||||
|
LogType("Height"),
|
||||||
|
LogType("Calories"),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
type LogType string
|
||||||
|
|
||||||
|
func ParseLogTypes(lts string) []LogType {
|
||||||
|
if lts == "" {
|
||||||
|
return AllLogTypes
|
||||||
|
}
|
||||||
|
|
||||||
|
ltsArr := []LogType{}
|
||||||
|
for _, lt := range strings.Split(lts, ",") {
|
||||||
|
lt_normalized := strings.Title(strings.ToLower(lt))
|
||||||
|
ltsArr = append(ltsArr, LogType(lt_normalized))
|
||||||
|
}
|
||||||
|
|
||||||
|
return ltsArr
|
||||||
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
Weight = LogType("Weight")
|
||||||
|
Height = LogType("Height")
|
||||||
|
Calories = LogType("Calories")
|
||||||
|
)
|
||||||
|
|
||||||
|
type StatLog struct {
|
||||||
|
ID uint64 `json:"id,omitempty"`
|
||||||
|
UserID uint64 `json:"userId,omitempty"`
|
||||||
Value float64 `json:"value"`
|
Value float64 `json:"value"`
|
||||||
|
Type LogType `json:"type"`
|
||||||
RecordedTS time.Time `json:"recordedTs"`
|
RecordedTS time.Time `json:"recordedTs"`
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in new issue