Private
Public Access
1
0

Merge branch 'develop' into bugfix/stats

This commit is contained in:
Sander Roosendaal
2018-07-12 13:38:37 +02:00
5 changed files with 61 additions and 14 deletions

View File

@@ -207,8 +207,15 @@ def summaryfromsplitdata(splitdata,data,filename,sep='|'):
except KeyError:
maxhr = 0
try:
avgpace = 500.*totaltime/totaldist
except (ZeroDivisionError,OverflowError):
avgpace = 0.
try:
restpace = 500.*resttime/restdistance
except (ZeroDivisionError,OverflowError):
restpace = 0.
velo = totaldist/totaltime
avgpower = 2.8*velo**(3.0)

View File

@@ -99,6 +99,7 @@ def processattachment(rower, fileobj, title, uploadoptions,testing=False):
)
try:
if workoutid:
if rower.getemailnotifications and not rower.emailbounced:
email_sent = send_confirm(
rower.user, title, link,
uploadoptions
@@ -108,6 +109,7 @@ def processattachment(rower, fileobj, title, uploadoptions,testing=False):
try:
time.sleep(10)
if workoutid:
if rower.getemailnotifications and not rower.emailbounced:
email_sent = send_confirm(
rower.user, title, link,
uploadoptions

View File

@@ -92,14 +92,33 @@ def get_strava_workouts(rower):
return 0
else:
stravaids = [int(item['id']) for item in res.json()]
stravadata = [{
'id':int(item['id']),
'elapsed_time':item['elapsed_time'],
'start_date':item['start_date'],
} for item in res.json()]
alldata = {}
for item in res.json():
alldata[item['id']] = item
wfailed = Workout.objects.filter(user=rower,uploadedtostrava=-1)
for w in wfailed:
for item in stravadata:
elapsed_time = item['elapsed_time']
start_date = item['start_date']
stravaid = item['id']
if arrow.get(start_date) == arrow.get(w.startdatetime):
if datetime.time(seconds=int(elapsed_time)) == w.duration:
w.uploadedtostrava = int(stravaid)
w.save()
knownstravaids = uniqify([
w.uploadedtostrava for w in Workout.objects.filter(user=rower)
])
newids = [stravaid for stravaid in stravaids if not stravaid in knownstravaids]

View File

@@ -9189,6 +9189,25 @@ def workout_stravaimport_view(request,message=""):
workouts = []
r = getrower(request.user)
stravaids = [int(item['id']) for item in res.json()]
stravadata = [{
'id':int(item['id']),
'elapsed_time':item['elapsed_time'],
'start_date':item['start_date'],
} for item in res.json()]
wfailed = Workout.objects.filter(user=r,uploadedtostrava=-1)
for w in wfailed:
for item in stravadata:
elapsed_time = item['elapsed_time']
start_date = item['start_date']
stravaid = item['id']
if arrow.get(start_date) == arrow.get(w.startdatetime):
if datetime.time(seconds=int(elapsed_time)) == w.duration:
w.uploadedtostrava = int(stravaid)
w.save()
knownstravaids = uniqify([
w.uploadedtostrava for w in Workout.objects.filter(user=r)
])