Private
Public Access
1
0

Merge branch 'develop' into feature/revisedimports

This commit is contained in:
Sander Roosendaal
2018-06-28 16:46:08 +02:00
15 changed files with 18299 additions and 18202 deletions

View File

@@ -94,19 +94,6 @@ def get_strava_workout_list(user):
return s
def add_stroke_data(user,stravaid,workoutid,startdatetime,csvfilename):
r = Rower.objects.get(user=user)
starttimeunix = arrow.get(startdatetime).timestamp
job = myqueue(queue,
handle_strava_import_stroke_data,
r.stravatoken,
stravaid,
workoutid,
starttimeunix,
csvfilename)
# gets all new Strava workouts for a rower
def get_strava_workouts(rower):
@@ -131,11 +118,11 @@ def get_strava_workouts(rower):
newids = [stravaid for stravaid in stravaids if not stravaid in knownstravaids]
for stravaid in newids:
workoutid = create_async_workout(alldata,rower.user,stravaid)
result = create_async_workout(alldata,rower.user,stravaid)
return 1
def create_async_workout(alldata,user,stravaid):
def create_async_workout(alldata,user,stravaid,debug=False):
data = alldata[stravaid]
r = Rower.objects.get(user=user)
distance = data['distance']
@@ -200,29 +187,38 @@ def create_async_workout(alldata,user,stravaid):
code = uuid4().hex[:16]
)
w = Workout(
user=r,
workouttype = workouttype,
name = title,
date = workoutdate,
starttime = starttime,
startdatetime = rowdatetime,
timezone = thetimezone,
duration = duration,
distance=distance,
weightcategory = weightcategory,
uploadedtostrava = stravaid,
csvfilename = csvfilename,
notes = ''
)
# w = Workout(
# user=r,
# workouttype = workouttype,
# name = title,
# date = workoutdate,
# starttime = starttime,
# startdatetime = rowdatetime,
# timezone = thetimezone,
# duration = duration,
# distance=distance,
# weightcategory = weightcategory,
# uploadedtostrava = stravaid,
# csvfilename = csvfilename,
# notes = ''
# )
w.save()
# Check if workout has stroke data, and get the stroke data
result = add_stroke_data(user,stravaid,w.id,rowdatetime,csvfilename)
starttimeunix = arrow.get(rowdatetime).timestamp
return w.id
job = myqueue(queue,
handle_strava_import_stroke_data,
title,
user.email,
r.stravatoken,
stravaid,
starttimeunix,
csvfilename,
)
return 1
from utils import get_strava_stream