Private
Public Access
1
0

also working for non oarlock workouts now - still naive implementation

This commit is contained in:
Sander Roosendaal
2021-04-04 19:58:04 +02:00
parent 13391c0e40
commit 6be21a0a8a
3 changed files with 18 additions and 5 deletions

View File

@@ -1856,6 +1856,7 @@ parsers = {
def parsenonpainsled(fileformat,f2,summary,startdatetime=''): def parsenonpainsled(fileformat,f2,summary,startdatetime=''):
try: try:
row = parsers[fileformat](f2) row = parsers[fileformat](f2)
print(row,'jet')
if startdatetime != '': if startdatetime != '':
row.rowdatetime = arrow.get(startdatetime).datetime row.rowdatetime = arrow.get(startdatetime).datetime
hasrecognized = True hasrecognized = True

View File

@@ -44,13 +44,13 @@ oauth_data = {
'client_id': NK_CLIENT_ID, 'client_id': NK_CLIENT_ID,
'client_secret': NK_CLIENT_SECRET, 'client_secret': NK_CLIENT_SECRET,
'redirect_uri': NK_REDIRECT_URI, 'redirect_uri': NK_REDIRECT_URI,
'autorization_uri': "https:#oauth-stage.nkrowlink.com/oauth/authorize", 'autorization_uri': "https://oauth-stage.nkrowlink.com/oauth/authorize",
'content_type': 'application/json', 'content_type': 'application/json',
'tokenname': 'nktoken', 'tokenname': 'nktoken',
'refreshtokenname': 'nkrefreshtoken', 'refreshtokenname': 'nkrefreshtoken',
'expirydatename': 'nktokenexpirydate', 'expirydatename': 'nktokenexpirydate',
'bearer_auth': True, 'bearer_auth': True,
'base_url': "https:#oauth-stage.nkrowlink.com/oauth/token", 'base_url': "https://oauth-stage.nkrowlink.com/oauth/token",
'scope':'read', 'scope':'read',
} }
@@ -287,13 +287,17 @@ def get_workout(user,nkid):
df = pd.DataFrame.from_dict(strokeData) df = pd.DataFrame.from_dict(strokeData)
oarlockData = df['oarlockStrokes'] oarlockData = df['oarlockStrokes']
oarlockData = oarlockData.apply(lambda x:getdict(x, seatIndex=1)) oarlockData = oarlockData.apply(lambda x:getdict(x, seatIndex=1))
df2 = pd.DataFrame.from_records(oarlockData.values) df2 = pd.DataFrame.from_records(oarlockData.values)
df.set_index('timestamp') df.set_index('timestamp')
df2.set_index('timestamp')
df = df.merge(df2,left_index=True,right_index=True) if not df2.empty:
df = df.rename(columns={"timestamp_x":"timestamp"}) df2.set_index('timestamp')
df = df.merge(df2,left_index=True,right_index=True)
df = df.rename(columns={"timestamp_x":"timestamp"})
df = df.drop('oarlockStrokes',axis=1) df = df.drop('oarlockStrokes',axis=1)
df.sort_values(by='timestamp',ascending=True,inplace=True) df.sort_values(by='timestamp',ascending=True,inplace=True)
df.fillna(inplace=True,method='ffill') df.fillna(inplace=True,method='ffill')
@@ -321,5 +325,6 @@ def get_workout(user,nkid):
# not to_csv and run upload API! # not to_csv and run upload API!
#strokedata = df.to_json(orient='records') #strokedata = df.to_json(orient='records')
#df.to_csv('~/Downloads/nk_logbook.csv')
return workoutdata, df return workoutdata, df

View File

@@ -4870,6 +4870,7 @@ def workout_upload_api(request):
q = request.POST q = request.POST
post_data = {k: q.getlist(k) if len(q.getlist(k))>1 else v for k, v in q.items()} post_data = {k: q.getlist(k) if len(q.getlist(k))>1 else v for k, v in q.items()}
# only allow local host # only allow local host
hostt = request.get_host().split(':') hostt = request.get_host().split(':')
if hostt[0] not in ['localhost','127.0.0.1','dev.rowsandall.com','rowsandall.com']: if hostt[0] not in ['localhost','127.0.0.1','dev.rowsandall.com','rowsandall.com']:
@@ -4916,6 +4917,12 @@ def workout_upload_api(request):
except KeyError: except KeyError:
c2id = '' c2id = ''
try:
nkid = post_data['nkid']
except KeyError:
nkid = ''
try: try:
rp3id = post_data['rp3id'] rp3id = post_data['rp3id']
except KeyError: except KeyError: