Private
Public Access
1
0
This commit is contained in:
Sander Roosendaal
2021-05-04 08:50:52 +02:00
parent 6f615c4ccc
commit 652d972411
4 changed files with 15 additions and 26 deletions

View File

@@ -2435,7 +2435,7 @@ def getsmallrowdata_db(columns, ids=[], doclean=True,workstrokesonly=True,comput
else:
try:
df = pd.read_parquet(csvfilenames[0],columns=columns)
except (OSError,ArrowInvalid):
except (OSError,ArrowInvalid,IndexError):
rowdata,row = getrowdata(id=ids[0])
if rowdata and len(rowdata.df): # pragma: no cover
data = dataprep(rowdata.df,id=ids[0],bands=True,otwpower=True,barchart=True)

View File

@@ -2,6 +2,7 @@ from rowers.imports import *
import datetime
import requests
from requests import Session, Request
from requests_oauthlib import OAuth1,OAuth1Session
from requests_oauthlib.oauth1_session import TokenRequestDenied
from requests import Request, Session
@@ -302,27 +303,17 @@ def ps_to_garmin(ps,r):
lijst.append(gstep)
payload['steps'] = lijst
url = 'https://apis.garmin.com/training-api/workout/'
garmin = OAuth1Session(oauth_data['client_id'],
client_secret=oauth_data['client_secret'],
resource_owner_key=r.garmintoken,
resource_owner_secret=r.garminrefreshtoken,
signature_method='HMAC-SHA1'
signature_method='HMAC-SHA1',
encoding='base64'
)
url = 'https://apis.garmin.com/training-api/workout/'
garminauth = OAuth1(
client_key=oauth_data['client_id'],
client_secret=oauth_data['client_secret'],
resource_owner_key=r.garmintoken,
resource_owner_secret=r.garminrefreshtoken,
signature_method='HMAC-SHA1'
)
response = garmin.post(url,data=payload)
#POST /training-api/workout?undefined HTTP/1.1

View File

@@ -3158,7 +3158,7 @@ class Workout(models.Model):
timezone = models.CharField(default='UTC',
choices=timezones,
max_length=100)
distance = models.IntegerField(default=0,blank=True)
distance = models.IntegerField(default=0)
duration = models.TimeField(blank=True)
dragfactor = models.IntegerField(default=0,blank=True)

View File

@@ -589,18 +589,15 @@ def step_to_time_dist(step,avgspeed = 3.2,ftp=200,ftspm=25,ftv=3.7):
seconds = 0
distance = 0
rscore = 0
durationtype = step['durationType']
durationtype = step.get('durationType',0)
value = step.get('durationValue',0)
if step['durationValue'] == 0: # pragma: no cover
if value == 0: # pragma: no cover
return 0,0,0
try:
targettype = step['targetType']
except KeyError: # pragma: no cover
targettype = 0
targettype = step.get('targetType',0)
if durationtype == 'Time':
value = step['durationValue']
seconds = value/1000.
distance = avgspeed*seconds
rscore = 60.*seconds/3600.
@@ -616,6 +613,8 @@ def step_to_time_dist(step,avgspeed = 3.2,ftp=200,ftspm=25,ftv=3.7):
elif valuelow != 0 and valuehigh != 0: # pragma: no cover
distance = seconds*(valuelow+valuehigh)/2.
velomid = (valuelow+valuehigh)/2000.
else:
velomid = avgspeed
veloratio = (velomid/ftv)**(3.0)
rscoreperhour = 100.*veloratio
@@ -657,11 +656,10 @@ def step_to_time_dist(step,avgspeed = 3.2,ftp=200,ftspm=25,ftv=3.7):
rscore = 100*(avgpower/ftp)*seconds/3600.
return seconds,distance,rscore
elif durationtype == 'Distance': # pragma: no cover
value = step['durationValue']
elif durationtype == 'Distance':
distance = value/100.
seconds = distance/avgspeed
rscore = 60*seconds/3600.
rscore = 60.*float(seconds)/3600.
if targettype == 'Speed':
value = step.get('targetValue',0)