Merge branch 'develop' into feature/workoutfit
This commit is contained in:
@@ -147,7 +147,7 @@ def add_stroke_data(user,c2id,workoutid,startdatetime,csvfilename,
|
|||||||
s = "Token expired. Needs to refresh."
|
s = "Token expired. Needs to refresh."
|
||||||
return custom_exception_handler(401,s)
|
return custom_exception_handler(401,s)
|
||||||
else:
|
else:
|
||||||
starttimeunix = arrow.get(startdatetime).timestamp
|
starttimeunix = arrow.get(startdatetime).timestamp()
|
||||||
|
|
||||||
job = myqueue(queue,
|
job = myqueue(queue,
|
||||||
handle_c2_import_stroke_data,
|
handle_c2_import_stroke_data,
|
||||||
@@ -212,7 +212,8 @@ def get_c2_workouts(rower,do_async=True):
|
|||||||
rower.user.id,
|
rower.user.id,
|
||||||
rower.c2token,
|
rower.c2token,
|
||||||
c2id,
|
c2id,
|
||||||
counter
|
counter,
|
||||||
|
rower.defaulttimezone
|
||||||
)
|
)
|
||||||
#res = handle_c2_async_workout(alldata,rower.user.id,rower.c2token,c2id,counter)
|
#res = handle_c2_async_workout(alldata,rower.user.id,rower.c2token,c2id,counter)
|
||||||
counter = counter+1
|
counter = counter+1
|
||||||
@@ -296,7 +297,7 @@ def create_async_workout(alldata,user,c2id):
|
|||||||
cum_time = res[0]
|
cum_time = res[0]
|
||||||
lapidx = res[1]
|
lapidx = res[1]
|
||||||
|
|
||||||
starttimeunix = arrow.get(startdatetime).timestamp
|
starttimeunix = arrow.get(startdatetime).timestamp()
|
||||||
starttimeunix = starttimeunix-cum_time.max()
|
starttimeunix = starttimeunix-cum_time.max()
|
||||||
|
|
||||||
unixtime = cum_time+starttimeunix
|
unixtime = cum_time+starttimeunix
|
||||||
@@ -1194,7 +1195,7 @@ def add_workout_from_data(user,importid,data,strokedata,
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
comments = ''
|
comments = ''
|
||||||
|
|
||||||
starttimeunix = arrow.get(rowdatetime).timestamp
|
starttimeunix = arrow.get(rowdatetime).timestamp()
|
||||||
|
|
||||||
res = make_cumvalues(0.1*strokedata['t'])
|
res = make_cumvalues(0.1*strokedata['t'])
|
||||||
cum_time = res[0]
|
cum_time = res[0]
|
||||||
|
|||||||
@@ -1401,7 +1401,7 @@ def create_row_df(r,distance,duration,startdatetime,workouttype='rower',
|
|||||||
if nr_strokes == 0:
|
if nr_strokes == 0:
|
||||||
nr_strokes = 100
|
nr_strokes = 100
|
||||||
|
|
||||||
unixstarttime = arrow.get(startdatetime).timestamp
|
unixstarttime = arrow.get(startdatetime).timestamp()
|
||||||
|
|
||||||
|
|
||||||
if not avgspm:
|
if not avgspm:
|
||||||
@@ -2286,7 +2286,7 @@ def new_workout_from_df(r, df,
|
|||||||
df.rename(columns=columndict, inplace=True)
|
df.rename(columns=columndict, inplace=True)
|
||||||
|
|
||||||
#starttimeunix = mktime(startdatetime.utctimetuple())
|
#starttimeunix = mktime(startdatetime.utctimetuple())
|
||||||
starttimeunix = arrow.get(startdatetime).timestamp
|
starttimeunix = arrow.get(startdatetime).timestamp()
|
||||||
df[' ElapsedTime (sec)'] = df['TimeStamp (sec)']
|
df[' ElapsedTime (sec)'] = df['TimeStamp (sec)']
|
||||||
|
|
||||||
df['TimeStamp (sec)'] = df['TimeStamp (sec)'] + starttimeunix
|
df['TimeStamp (sec)'] = df['TimeStamp (sec)'] + starttimeunix
|
||||||
@@ -2531,6 +2531,8 @@ def read_cols_df_sql(ids, columns, convertnewtons=True):
|
|||||||
columns = list(set(columns))
|
columns = list(set(columns))
|
||||||
ids = [int(id) for id in ids]
|
ids = [int(id) for id in ids]
|
||||||
|
|
||||||
|
df = pd.DataFrame()
|
||||||
|
|
||||||
|
|
||||||
if len(ids) == 0:
|
if len(ids) == 0:
|
||||||
return pd.DataFrame(),extracols
|
return pd.DataFrame(),extracols
|
||||||
|
|||||||
@@ -181,8 +181,8 @@ def imports_do_refresh_token(refreshtoken,oauth_data,access_token=''):
|
|||||||
expires_in = token_json['expires_in']
|
expires_in = token_json['expires_in']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
try:
|
try:
|
||||||
expires_at = arrow.get(token_json['expires_at']).timestamp
|
expires_at = arrow.get(token_json['expires_at']).timestamp()
|
||||||
expires_in = expires_at - arrow.now().timestamp
|
expires_in = expires_at - arrow.now().timestamp()
|
||||||
except KeyError:
|
except KeyError:
|
||||||
expires_in = 0
|
expires_in = 0
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -116,6 +116,7 @@ class UserFullnameChoiceField(forms.ModelChoiceField):
|
|||||||
def label_from_instance(self,obj):
|
def label_from_instance(self,obj):
|
||||||
return obj.get_full_name()
|
return obj.get_full_name()
|
||||||
|
|
||||||
|
|
||||||
# model for configurable template field
|
# model for configurable template field
|
||||||
class TemplateListField(models.TextField):
|
class TemplateListField(models.TextField):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
|
|||||||
@@ -374,7 +374,7 @@ def add_workout_from_data(user,importid,data,strokedata,source='runkeeper',
|
|||||||
except:
|
except:
|
||||||
rowdatetime = datetime.strptime(data['date'],"%Y-%m-%d %H:%M:%S")
|
rowdatetime = datetime.strptime(data['date'],"%Y-%m-%d %H:%M:%S")
|
||||||
rowdatetime = thetimezone.localize(rowdatetime).astimezone(utc)
|
rowdatetime = thetimezone.localize(rowdatetime).astimezone(utc)
|
||||||
starttimeunix = arrow.get(rowdatetime).timestamp
|
starttimeunix = arrow.get(rowdatetime).timestamp()
|
||||||
#starttimeunix = mktime(rowdatetime.utctimetuple())
|
#starttimeunix = mktime(rowdatetime.utctimetuple())
|
||||||
starttimeunix += utcoffset*3600
|
starttimeunix += utcoffset*3600
|
||||||
|
|
||||||
|
|||||||
@@ -350,7 +350,7 @@ def add_workout_from_data(user,importid,data,strokedata,source='sporttracks',
|
|||||||
except:
|
except:
|
||||||
rowdatetime = datetime.datetime.strptime(data['date'],"%Y-%m-%d %H:%M:%S")
|
rowdatetime = datetime.datetime.strptime(data['date'],"%Y-%m-%d %H:%M:%S")
|
||||||
rowdatetime = thetimezone.localize(rowdatetime).astimezone(utc)
|
rowdatetime = thetimezone.localize(rowdatetime).astimezone(utc)
|
||||||
starttimeunix = arrow.get(rowdatetime).timestamp
|
starttimeunix = arrow.get(rowdatetime).timestamp()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
title = data['name']
|
title = data['name']
|
||||||
|
|||||||
@@ -350,7 +350,7 @@ def create_async_workout(alldata,user,stravaid,debug=False):
|
|||||||
|
|
||||||
# Check if workout has stroke data, and get the stroke data
|
# Check if workout has stroke data, and get the stroke data
|
||||||
|
|
||||||
starttimeunix = arrow.get(rowdatetime).timestamp
|
starttimeunix = arrow.get(rowdatetime).timestamp()
|
||||||
|
|
||||||
result = handle_strava_import_stroke_data(
|
result = handle_strava_import_stroke_data(
|
||||||
title,
|
title,
|
||||||
@@ -630,7 +630,7 @@ def add_workout_from_data(user,importid,data,strokedata,
|
|||||||
except:
|
except:
|
||||||
title = ''
|
title = ''
|
||||||
|
|
||||||
starttimeunix = arrow.get(rowdatetime).timestamp
|
starttimeunix = arrow.get(rowdatetime).timestamp()
|
||||||
|
|
||||||
res = make_cumvalues(0.1*strokedata['t'])
|
res = make_cumvalues(0.1*strokedata['t'])
|
||||||
cum_time = res[0]
|
cum_time = res[0]
|
||||||
|
|||||||
@@ -2951,7 +2951,7 @@ def handle_rp3_async_workout(userid,rp3token,rp3id,startdatetime,debug=False,**k
|
|||||||
return workoutid
|
return workoutid
|
||||||
|
|
||||||
@app.task
|
@app.task
|
||||||
def handle_c2_async_workout(alldata,userid,c2token,c2id,delaysec,debug=False,**kwargs):
|
def handle_c2_async_workout(alldata,userid,c2token,c2id,delaysec,defaulttimezone,debug=False,**kwargs):
|
||||||
time.sleep(delaysec)
|
time.sleep(delaysec)
|
||||||
data = alldata[c2id]
|
data = alldata[c2id]
|
||||||
splitdata = None
|
splitdata = None
|
||||||
@@ -2986,7 +2986,7 @@ def handle_c2_async_workout(alldata,userid,c2token,c2id,delaysec,debug=False,**k
|
|||||||
try:
|
try:
|
||||||
timezone_str = tz(data['timezone'])
|
timezone_str = tz(data['timezone'])
|
||||||
except:
|
except:
|
||||||
timezone_str = 'UTC'
|
timezone_str = defaulttimezone
|
||||||
|
|
||||||
workoutdate = startdatetime.astimezone(
|
workoutdate = startdatetime.astimezone(
|
||||||
pytz.timezone(timezone_str)
|
pytz.timezone(timezone_str)
|
||||||
@@ -3021,7 +3021,7 @@ def handle_c2_async_workout(alldata,userid,c2token,c2id,delaysec,debug=False,**k
|
|||||||
cum_time = res[0]
|
cum_time = res[0]
|
||||||
lapidx = res[1]
|
lapidx = res[1]
|
||||||
|
|
||||||
starttimeunix = arrow.get(startdatetime).timestamp
|
starttimeunix = arrow.get(startdatetime).timestamp()
|
||||||
starttimeunix = starttimeunix-cum_time.max()
|
starttimeunix = starttimeunix-cum_time.max()
|
||||||
|
|
||||||
unixtime = cum_time+starttimeunix
|
unixtime = cum_time+starttimeunix
|
||||||
@@ -3141,7 +3141,7 @@ def handle_c2_async_workout(alldata,userid,c2token,c2id,delaysec,debug=False,**k
|
|||||||
|
|
||||||
# set distance, time
|
# set distance, time
|
||||||
query = "UPDATE `rowers_workout` SET `distance` = '%s', `duration` = '%s' WHERE `id` = '%s'" % (distance, duration, workoutid)
|
query = "UPDATE `rowers_workout` SET `distance` = '%s', `duration` = '%s' WHERE `id` = '%s'" % (distance, duration, workoutid)
|
||||||
|
|
||||||
with engine.connect() as conn, conn.begin():
|
with engine.connect() as conn, conn.begin():
|
||||||
result = conn.execute(query)
|
result = conn.execute(query)
|
||||||
|
|
||||||
@@ -3357,7 +3357,7 @@ def fetch_strava_workout(stravatoken,oauth_data,stravaid,csvfilename,userid,debu
|
|||||||
except:
|
except:
|
||||||
title = ''
|
title = ''
|
||||||
|
|
||||||
starttimeunix = arrow.get(rowdatetime).timestamp
|
starttimeunix = arrow.get(rowdatetime).timestamp()
|
||||||
|
|
||||||
res = make_cumvalues(0.1*strokedata['t'])
|
res = make_cumvalues(0.1*strokedata['t'])
|
||||||
cum_time = res[0]
|
cum_time = res[0]
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ def createunderarmourworkoutdata(w):
|
|||||||
#t = row.df.loc[:,'TimeStamp (sec)'].values-10*row.df.ix[0,'TimeStamp (sec)']
|
#t = row.df.loc[:,'TimeStamp (sec)'].values-10*row.df.ix[0,'TimeStamp (sec)']
|
||||||
t = row.df.loc[:,'TimeStamp (sec)'].values #-row.df.ix[0,'TimeStamp (sec)']
|
t = row.df.loc[:,'TimeStamp (sec)'].values #-row.df.ix[0,'TimeStamp (sec)']
|
||||||
|
|
||||||
# t += arrow.get(st).timestamp
|
# t += arrow.get(st).timestamp()
|
||||||
|
|
||||||
# t[0] = t[1]
|
# t[0] = t[1]
|
||||||
|
|
||||||
@@ -405,7 +405,7 @@ def add_workout_from_data(user,importid,data,strokedata,
|
|||||||
except:
|
except:
|
||||||
rowdatetime = datetime.strptime(data['date'],"%Y-%m-%d %H:%M:%S")
|
rowdatetime = datetime.strptime(data['date'],"%Y-%m-%d %H:%M:%S")
|
||||||
rowdatetime = thetimezone.localize(rowdatetime).astimezone(utc)
|
rowdatetime = thetimezone.localize(rowdatetime).astimezone(utc)
|
||||||
starttimeunix = arrow.get(rowdatetime).timestamp
|
starttimeunix = arrow.get(rowdatetime).timestamp()
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -2217,8 +2217,8 @@ def rankings_view2(request,userid=0,
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
lastupdatedtime = arrow.get(lastupdated).timestamp
|
lastupdatedtime = arrow.get(lastupdated).timestamp()
|
||||||
current_time = arrow.utcnow().timestamp
|
current_time = arrow.utcnow().timestamp()
|
||||||
|
|
||||||
deltatime_seconds = current_time - lastupdatedtime
|
deltatime_seconds = current_time - lastupdatedtime
|
||||||
recalc = False
|
recalc = False
|
||||||
|
|||||||
@@ -240,7 +240,7 @@ def workout_csvemail_view(request,id=0):
|
|||||||
filename = code+'.csv'
|
filename = code+'.csv'
|
||||||
|
|
||||||
rowdate = rowdata.rowdatetime
|
rowdate = rowdata.rowdatetime
|
||||||
starttimeunix = arrow.get(rowdate).timestamp
|
starttimeunix = arrow.get(rowdate).timestamp()
|
||||||
df = rowdata.df
|
df = rowdata.df
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -1319,7 +1319,7 @@ def add_workout_from_strokedata(user,importid,data,strokedata,
|
|||||||
except:
|
except:
|
||||||
title = ''
|
title = ''
|
||||||
|
|
||||||
starttimeunix = arrow.get(rowdatetime).timestamp
|
starttimeunix = arrow.get(rowdatetime).timestamp()
|
||||||
|
|
||||||
res = make_cumvalues(0.1*strokedata['t'])
|
res = make_cumvalues(0.1*strokedata['t'])
|
||||||
cum_time = res[0]
|
cum_time = res[0]
|
||||||
|
|||||||
@@ -2613,7 +2613,7 @@ def workout_downloadwind_view(request,id=0,
|
|||||||
startdatetime = dateutil.parser.parse("{}, {}".format(row.date,
|
startdatetime = dateutil.parser.parse("{}, {}".format(row.date,
|
||||||
row.starttime))
|
row.starttime))
|
||||||
|
|
||||||
starttimeunix = int(arrow.get(row.startdatetime).timestamp)
|
starttimeunix = int(arrow.get(row.startdatetime).timestamp())
|
||||||
#starttimeunix = int(mktime(startdatetime.utctimetuple()))
|
#starttimeunix = int(mktime(startdatetime.utctimetuple()))
|
||||||
avgtime = starttimeunix+avgtime
|
avgtime = starttimeunix+avgtime
|
||||||
winddata = get_wind_data(avglat,avglon,avgtime)
|
winddata = get_wind_data(avglat,avglon,avgtime)
|
||||||
@@ -2682,7 +2682,7 @@ def workout_downloadmetar_view(request,id=0,
|
|||||||
startdatetime = dateutil.parser.parse("{}, {}".format(row.date,
|
startdatetime = dateutil.parser.parse("{}, {}".format(row.date,
|
||||||
row.starttime))
|
row.starttime))
|
||||||
|
|
||||||
starttimeunix = arrow.get(row.startdatetime).timestamp
|
starttimeunix = arrow.get(row.startdatetime).timestamp()
|
||||||
#starttimeunix = int(mktime(startdatetime.utctimetuple()))
|
#starttimeunix = int(mktime(startdatetime.utctimetuple()))
|
||||||
avgtime = starttimeunix +avgtime
|
avgtime = starttimeunix +avgtime
|
||||||
winddata = get_metar_data(airportcode,avgtime)
|
winddata = get_metar_data(airportcode,avgtime)
|
||||||
@@ -3243,7 +3243,7 @@ def workout_erase_column_view(request, id=0,column=''):
|
|||||||
|
|
||||||
|
|
||||||
row.write_csv(w.csvfilename,gzip=True)
|
row.write_csv(w.csvfilename,gzip=True)
|
||||||
|
|
||||||
|
|
||||||
row,workout = dataprep.getrowdata(id=w.id)
|
row,workout = dataprep.getrowdata(id=w.id)
|
||||||
datadf = dataprep.dataprep(row.df,id=w.id)
|
datadf = dataprep.dataprep(row.df,id=w.id)
|
||||||
|
|||||||
Reference in New Issue
Block a user