changes
This commit is contained in:
@@ -2435,7 +2435,7 @@ def getsmallrowdata_db(columns, ids=[], doclean=True,workstrokesonly=True,comput
|
|||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
df = pd.read_parquet(csvfilenames[0],columns=columns)
|
df = pd.read_parquet(csvfilenames[0],columns=columns)
|
||||||
except (OSError,ArrowInvalid):
|
except (OSError,ArrowInvalid,IndexError):
|
||||||
rowdata,row = getrowdata(id=ids[0])
|
rowdata,row = getrowdata(id=ids[0])
|
||||||
if rowdata and len(rowdata.df): # pragma: no cover
|
if rowdata and len(rowdata.df): # pragma: no cover
|
||||||
data = dataprep(rowdata.df,id=ids[0],bands=True,otwpower=True,barchart=True)
|
data = dataprep(rowdata.df,id=ids[0],bands=True,otwpower=True,barchart=True)
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ from rowers.imports import *
|
|||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
from requests import Session, Request
|
||||||
from requests_oauthlib import OAuth1,OAuth1Session
|
from requests_oauthlib import OAuth1,OAuth1Session
|
||||||
from requests_oauthlib.oauth1_session import TokenRequestDenied
|
from requests_oauthlib.oauth1_session import TokenRequestDenied
|
||||||
from requests import Request, Session
|
from requests import Request, Session
|
||||||
@@ -302,27 +303,17 @@ def ps_to_garmin(ps,r):
|
|||||||
lijst.append(gstep)
|
lijst.append(gstep)
|
||||||
|
|
||||||
payload['steps'] = lijst
|
payload['steps'] = lijst
|
||||||
|
url = 'https://apis.garmin.com/training-api/workout/'
|
||||||
|
|
||||||
|
|
||||||
garmin = OAuth1Session(oauth_data['client_id'],
|
garmin = OAuth1Session(oauth_data['client_id'],
|
||||||
client_secret=oauth_data['client_secret'],
|
client_secret=oauth_data['client_secret'],
|
||||||
resource_owner_key=r.garmintoken,
|
resource_owner_key=r.garmintoken,
|
||||||
resource_owner_secret=r.garminrefreshtoken,
|
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)
|
response = garmin.post(url,data=payload)
|
||||||
|
|
||||||
#POST /training-api/workout?undefined HTTP/1.1
|
#POST /training-api/workout?undefined HTTP/1.1
|
||||||
|
|||||||
@@ -3158,7 +3158,7 @@ class Workout(models.Model):
|
|||||||
timezone = models.CharField(default='UTC',
|
timezone = models.CharField(default='UTC',
|
||||||
choices=timezones,
|
choices=timezones,
|
||||||
max_length=100)
|
max_length=100)
|
||||||
distance = models.IntegerField(default=0,blank=True)
|
distance = models.IntegerField(default=0)
|
||||||
duration = models.TimeField(blank=True)
|
duration = models.TimeField(blank=True)
|
||||||
dragfactor = models.IntegerField(default=0,blank=True)
|
dragfactor = models.IntegerField(default=0,blank=True)
|
||||||
|
|
||||||
|
|||||||
@@ -589,18 +589,15 @@ def step_to_time_dist(step,avgspeed = 3.2,ftp=200,ftspm=25,ftv=3.7):
|
|||||||
seconds = 0
|
seconds = 0
|
||||||
distance = 0
|
distance = 0
|
||||||
rscore = 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
|
return 0,0,0
|
||||||
|
|
||||||
try:
|
targettype = step.get('targetType',0)
|
||||||
targettype = step['targetType']
|
|
||||||
except KeyError: # pragma: no cover
|
|
||||||
targettype = 0
|
|
||||||
|
|
||||||
if durationtype == 'Time':
|
if durationtype == 'Time':
|
||||||
value = step['durationValue']
|
|
||||||
seconds = value/1000.
|
seconds = value/1000.
|
||||||
distance = avgspeed*seconds
|
distance = avgspeed*seconds
|
||||||
rscore = 60.*seconds/3600.
|
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
|
elif valuelow != 0 and valuehigh != 0: # pragma: no cover
|
||||||
distance = seconds*(valuelow+valuehigh)/2.
|
distance = seconds*(valuelow+valuehigh)/2.
|
||||||
velomid = (valuelow+valuehigh)/2000.
|
velomid = (valuelow+valuehigh)/2000.
|
||||||
|
else:
|
||||||
|
velomid = avgspeed
|
||||||
|
|
||||||
veloratio = (velomid/ftv)**(3.0)
|
veloratio = (velomid/ftv)**(3.0)
|
||||||
rscoreperhour = 100.*veloratio
|
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.
|
rscore = 100*(avgpower/ftp)*seconds/3600.
|
||||||
|
|
||||||
return seconds,distance,rscore
|
return seconds,distance,rscore
|
||||||
elif durationtype == 'Distance': # pragma: no cover
|
elif durationtype == 'Distance':
|
||||||
value = step['durationValue']
|
|
||||||
distance = value/100.
|
distance = value/100.
|
||||||
seconds = distance/avgspeed
|
seconds = distance/avgspeed
|
||||||
rscore = 60*seconds/3600.
|
rscore = 60.*float(seconds)/3600.
|
||||||
|
|
||||||
if targettype == 'Speed':
|
if targettype == 'Speed':
|
||||||
value = step.get('targetValue',0)
|
value = step.get('targetValue',0)
|
||||||
|
|||||||
Reference in New Issue
Block a user