Skip to content

Commit

Permalink
fix: other type may cause nike to strava bug
Browse files Browse the repository at this point in the history
  • Loading branch information
yihong0618 committed Mar 10, 2021
1 parent ed1b31c commit d5ed915
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion scripts/nike_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,9 @@ def make_new_gpxs(files):
return
# ALL save name using utc if you want local please offset
gpx_name = str(json_data["end_epoch_ms"])
gpx_files.append(os.path.join(GPX_FOLDER, str(gpx_name) + ".gpx"))
parsed_data = parse_activity_data(json_data)
if parsed_data:
gpx_files.append(os.path.join(GPX_FOLDER, str(gpx_name) + ".gpx"))
save_gpx(parsed_data, gpx_name)
return gpx_files

Expand Down
10 changes: 9 additions & 1 deletion scripts/nike_to_strava_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,15 @@ def get_last_time(client):
if there is no activities cause exception return 0
"""
try:
activate = next(client.get_activities(limit=3))
activate = None
activates = client.get_activities(limit=10)
# for else in python if you don't know please google it.
for a in activates:
if a.type == "Run":
activate = a
break
else:
return 0
# add 30 minutes to make sure after the end of this activate
end_date = activate.start_date + activate.elapsed_time + timedelta(minutes=30)
return int(datetime.timestamp(end_date) * 1000)
Expand Down

1 comment on commit d5ed915

@vercel
Copy link

@vercel vercel bot commented on d5ed915 Mar 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.