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},
},
})
}