~hokiegeek/fitstrava

f5bac16231013630f1c8e6996ecfbe398a034d23 — HokieGeek 6 months ago 149fb9b main v0.2.0
Done and done
2 files changed, 14 insertions(+), 8 deletions(-)

M cmd/fitstrava/main.go
M strava.go
M cmd/fitstrava/main.go => cmd/fitstrava/main.go +8 -7
@@ 166,7 166,9 @@ func main() {
		activity fitstrava.FitbitActivity
	}

	fmt.Println("- Synching")
	if len(unsynched) > 0 {
		fmt.Println("- Synching")
	}
	errors := make([]syncError, 0)
	for _, a := range unsynched {
		fmt.Printf("... %d,%s,%s\n", a.LogID, a.ActivityName, a.StartTime)


@@ 188,8 190,7 @@ func main() {
			}); err != nil {
				errors = append(errors, syncError{err: err, activity: a})
			}
			/*
			 */
			time.Sleep(2 * time.Second)
		} else {
			errors = append(errors, syncError{err: fmt.Errorf("could not parse StartTime: %v", err), activity: a})
		}


@@ 198,14 199,14 @@ func main() {
	if len(errors) > 0 {
		fmt.Println("- Errors")
		for _, e := range errors {
			fmt.Printf(" %s %s: %s", e.activity.ActivityName, e.activity.StartTime, e.err)
			fmt.Printf(" %s %s: %s\n", e.activity.ActivityName, e.activity.StartTime, e.err)
		}
	}
	/*
		if err := fitstrava.StravaCreateActivity(strava, fitstrava.StravaNewActivity{
			Name:           "testing (42)",
			Type:           "Workout",
			Description:    fmt.Sprintf(`{"fitbit_id": %d}`, 42),
			Name: "testing (42)",
			Type: "Workout",
			// Description:    fmt.Sprintf(`{"fitbit_id": %d}`, 42),
			StartDate:      time.Now(),
			ElapsedSeconds: 1,
		}); err != nil {

M strava.go => strava.go +6 -1
@@ 194,7 194,7 @@ type StravaActivity struct {
	HasKudoed                  bool              `json:"has_kudoed"`
	SufferScore                int64             `json:"suffer_score,omitempty"`
	Description                string            `json:"description"`
	Calories                   int64             `json:"calories"`
	Calories                   float64           `json:"calories"`
	PerceivedExertion          interface{}       `json:"perceived_exertion"`
	PreferPerceivedExertion    interface{}       `json:"prefer_perceived_exertion"`
	SegmentEfforts             []interface{}     `json:"segment_efforts"`


@@ 247,6 247,11 @@ func StravaGetActivities(strava StravaClient, after time.Time) ([]StravaActivity
		defer resp.Body.Close()

		if resp.StatusCode != http.StatusOK {
			if resp.StatusCode == http.StatusTooManyRequests {
				// X-Ratelimit-Limit:[100,1000]
				// X-Ratelimit-Usage:[224,251]
				fmt.Printf("%+v\n", resp.Header)
			}
			return nil, stravaHttpError(resp.Body, fmt.Sprintf("could not get Strava activities: %s", resp.Status))
			/*
				var serr stravaErrorResponse