parent
375193f9f4
commit
2373629a94
@ -1,12 +1,44 @@
|
||||
package services
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
type WeightLog struct {
|
||||
ID uint64 `json:"id"`
|
||||
UserID uint64 `json:"userId"`
|
||||
var (
|
||||
AllLogTypes = []LogType{
|
||||
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"`
|
||||
Type LogType `json:"type"`
|
||||
RecordedTS time.Time `json:"recordedTs"`
|
||||
}
|
||||
|
Loading…
Reference in new issue