-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsample.go
49 lines (41 loc) · 986 Bytes
/
sample.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
48
49
package request
type Sample interface {
GetTimestamp() *Timestamp
}
type QtySample struct {
Date *Timestamp `json:"date"`
Qty float64 `json:"qty"`
}
func (s *QtySample) GetTimestamp() *Timestamp {
return s.Date
}
type MinMaxAvgSample struct {
Date *Timestamp `json:"date"`
Max float64 `json:"max"`
Min float64 `json:"min"`
Avg float64 `json:"avg"`
}
func (s *MinMaxAvgSample) GetTimestamp() *Timestamp {
return s.Date
}
type SleepSample struct {
Date *Timestamp `json:"date"`
Asleep float64 `json:"asleep"`
InBed float64 `json:"inBed"`
SleepSource string `json:"sleepSource"`
InBedSource string `json:"inBedSource"`
}
func (s *SleepSample) GetTimestamp() *Timestamp {
return s.Date
}
func newEmptySample(metricType string) Sample {
switch metricType {
case MetricTypeQty:
return &QtySample{}
case MetricTypeMinMaxAvg:
return &MinMaxAvgSample{}
case MetricTypeSleep:
return &SleepSample{}
}
return nil
}