type Activity struct {
Start time.Time
End time.Time
- Type int64
+ Type string
}
func (a Activity) String() string {
- return fmt.Sprintf("%s-%s %d", a.Start.Format("15:04:05"), a.End.Format("15:04:05"), a.Type)
+ return fmt.Sprintf("%s-%s %q", a.Start.Format("15:04:05"), a.End.Format("15:04:05"), a.Type)
}
func (c *Client) SetActivities(ctx context.Context, activities []Activity, startOfDay time.Time) error {
for _, a := range activities {
startTimeNanos := a.Start.UnixNano()
endTimeNanos := a.End.UnixNano()
+ activityType := ParseFitbitActivity(a.Type)
for _, p := range dataset.Point {
- if p.StartTimeNanos == startTimeNanos && p.EndTimeNanos == endTimeNanos && p.Value[0].IntVal == a.Type {
+ if p.StartTimeNanos == startTimeNanos && p.EndTimeNanos == endTimeNanos && p.Value[0].IntVal == activityType {
log.Debugf(ctx, "activity %s already stored in Google Fit", a)
continue Next
}
StartTimeNanos: startTimeNanos,
EndTimeNanos: endTimeNanos,
Value: []*fitness.Value{
- &fitness.Value{IntVal: a.Type},
+ &fitness.Value{IntVal: activityType},
},
})
}
activities = append(activities, gfit.Activity{
Start: startTime,
End: endTime,
- Type: gfit.ParseFitbitActivity(a.Name),
+ Type: a.Name,
})
}
if err := gfitClient.SetActivities(ctx, activities, tm); err != nil {
}
switch stg.Level {
case fitbit.SleepLevelDeep:
- a.Type = 110 // Deep sleep
+ a.Type = "Deep sleep"
case fitbit.SleepLevelLight:
- a.Type = 109 // Light sleep
+ a.Type = "Light sleep"
case fitbit.SleepLevelREM:
- a.Type = 111 // REM sleep
+ a.Type = "REM sleep"
case fitbit.SleepLevelWake:
- a.Type = 112 // Awake (during sleep cycle)
+ a.Type = "Awake (during sleep cycle)"
default:
log.Warningf(ctx, "unexpected sleep level %v", stg.Level)
continue