-
Notifications
You must be signed in to change notification settings - Fork 0
/
model.go
47 lines (42 loc) · 1.03 KB
/
model.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package fitness
import "time"
type Activity struct {
ID int64 `json:"id"`
Type string `json:"type"`
Name string `json:"name"`
Week int `json:"week"`
Score int `json:"score"`
Calories int `json:"calories"`
}
type Week struct {
Week int `json:"week"`
Score int `json:"score"`
Calories int `json:"calories"`
Activities []*Activity `json:"activities"`
}
type Config struct {
Weeks []struct {
Start time.Time `json:"start"`
End time.Time `json:"end"`
} `json:"weeks"`
Epic []struct {
Type string `json:"type"`
Minutes int `json:"minutes"`
Multiplier float64 `json:"multiplier"`
} `json:"epic"`
Calories []struct {
ID int64 `json:"id"`
Override int `json:"override"`
} `json:"calories"`
}
func (c *Config) DateRange() (start, end time.Time) {
for _, week := range c.Weeks {
if start.IsZero() || week.Start.Before(start) {
start = week.Start
}
if end.IsZero() || week.End.After(end) {
end = week.End
}
}
return
}