From: Florian Forster Date: Wed, 24 Jan 2018 19:42:07 +0000 (+0100) Subject: Package gfit: Add debug output to SetActivities(). X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=a2b86ab96b046d7cccd96b066121ffa71e0eaf46;p=kraftakt.git Package gfit: Add debug output to SetActivities(). --- diff --git a/gfit/gfit.go b/gfit/gfit.go index eca961c..fb66862 100644 --- a/gfit/gfit.go +++ b/gfit/gfit.go @@ -225,6 +225,10 @@ type Activity struct { Type int64 } +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) +} + func (c *Client) SetActivities(ctx context.Context, activities []Activity, startOfDay time.Time) error { dataStreamID := DataStreamID(&fitness.DataSource{ DataType: &fitness.DataType{ @@ -249,13 +253,13 @@ Next: endTimeNanos := a.End.UnixNano() for _, p := range res.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 == a.Type { + log.Debugf(ctx, "activity %s already stored in Google Fit", a) continue Next } } + log.Debugf(ctx, "activity %s will be added to Google Fit", a) dataPoints = append(dataPoints, &fitness.DataPoint{ DataTypeName: dataTypeNameActivitySegment, StartTimeNanos: startTimeNanos,