Private
Public Access
1
0

replacing timestamp with call to timestamp

This commit is contained in:
Sander Roosendaal
2021-03-01 08:59:13 +01:00
parent c801dc4d93
commit 33188f3322
13 changed files with 28 additions and 26 deletions

View File

@@ -147,7 +147,7 @@ def add_stroke_data(user,c2id,workoutid,startdatetime,csvfilename,
s = "Token expired. Needs to refresh."
return custom_exception_handler(401,s)
else:
starttimeunix = arrow.get(startdatetime).timestamp
starttimeunix = arrow.get(startdatetime).timestamp()
job = myqueue(queue,
handle_c2_import_stroke_data,
@@ -212,7 +212,8 @@ def get_c2_workouts(rower,do_async=True):
rower.user.id,
rower.c2token,
c2id,
counter
counter,
rower.defaulttimezone
)
#res = handle_c2_async_workout(alldata,rower.user.id,rower.c2token,c2id,counter)
counter = counter+1
@@ -296,7 +297,7 @@ def create_async_workout(alldata,user,c2id):
cum_time = res[0]
lapidx = res[1]
starttimeunix = arrow.get(startdatetime).timestamp
starttimeunix = arrow.get(startdatetime).timestamp()
starttimeunix = starttimeunix-cum_time.max()
unixtime = cum_time+starttimeunix
@@ -1194,7 +1195,7 @@ def add_workout_from_data(user,importid,data,strokedata,
except KeyError:
comments = ''
starttimeunix = arrow.get(rowdatetime).timestamp
starttimeunix = arrow.get(rowdatetime).timestamp()
res = make_cumvalues(0.1*strokedata['t'])
cum_time = res[0]

View File

@@ -1401,7 +1401,7 @@ def create_row_df(r,distance,duration,startdatetime,workouttype='rower',
if nr_strokes == 0:
nr_strokes = 100
unixstarttime = arrow.get(startdatetime).timestamp
unixstarttime = arrow.get(startdatetime).timestamp()
if not avgspm:
@@ -2286,7 +2286,7 @@ def new_workout_from_df(r, df,
df.rename(columns=columndict, inplace=True)
#starttimeunix = mktime(startdatetime.utctimetuple())
starttimeunix = arrow.get(startdatetime).timestamp
starttimeunix = arrow.get(startdatetime).timestamp()
df[' ElapsedTime (sec)'] = df['TimeStamp (sec)']
df['TimeStamp (sec)'] = df['TimeStamp (sec)'] + starttimeunix

View File

@@ -181,8 +181,8 @@ def imports_do_refresh_token(refreshtoken,oauth_data,access_token=''):
expires_in = token_json['expires_in']
except KeyError:
try:
expires_at = arrow.get(token_json['expires_at']).timestamp
expires_in = expires_at - arrow.now().timestamp
expires_at = arrow.get(token_json['expires_at']).timestamp()
expires_in = expires_at - arrow.now().timestamp()
except KeyError:
expires_in = 0
try:

View File

@@ -111,6 +111,7 @@ class UserFullnameChoiceField(forms.ModelChoiceField):
def label_from_instance(self,obj):
return obj.get_full_name()
# model for configurable template field
class TemplateListField(models.TextField):
def __init__(self, *args, **kwargs):

View File

@@ -374,7 +374,7 @@ def add_workout_from_data(user,importid,data,strokedata,source='runkeeper',
except:
rowdatetime = datetime.strptime(data['date'],"%Y-%m-%d %H:%M:%S")
rowdatetime = thetimezone.localize(rowdatetime).astimezone(utc)
starttimeunix = arrow.get(rowdatetime).timestamp
starttimeunix = arrow.get(rowdatetime).timestamp()
#starttimeunix = mktime(rowdatetime.utctimetuple())
starttimeunix += utcoffset*3600

View File

@@ -350,7 +350,7 @@ def add_workout_from_data(user,importid,data,strokedata,source='sporttracks',
except:
rowdatetime = datetime.datetime.strptime(data['date'],"%Y-%m-%d %H:%M:%S")
rowdatetime = thetimezone.localize(rowdatetime).astimezone(utc)
starttimeunix = arrow.get(rowdatetime).timestamp
starttimeunix = arrow.get(rowdatetime).timestamp()
try:
title = data['name']

View File

@@ -350,7 +350,7 @@ def create_async_workout(alldata,user,stravaid,debug=False):
# 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(
title,
@@ -630,7 +630,7 @@ def add_workout_from_data(user,importid,data,strokedata,
except:
title = ''
starttimeunix = arrow.get(rowdatetime).timestamp
starttimeunix = arrow.get(rowdatetime).timestamp()
res = make_cumvalues(0.1*strokedata['t'])
cum_time = res[0]

View File

@@ -2951,7 +2951,7 @@ def handle_rp3_async_workout(userid,rp3token,rp3id,startdatetime,debug=False,**k
return workoutid
@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)
data = alldata[c2id]
splitdata = None
@@ -2986,7 +2986,7 @@ def handle_c2_async_workout(alldata,userid,c2token,c2id,delaysec,debug=False,**k
try:
timezone_str = tz(data['timezone'])
except:
timezone_str = 'UTC'
timezone_str = defaulttimezone
workoutdate = startdatetime.astimezone(
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]
lapidx = res[1]
starttimeunix = arrow.get(startdatetime).timestamp
starttimeunix = arrow.get(startdatetime).timestamp()
starttimeunix = starttimeunix-cum_time.max()
unixtime = cum_time+starttimeunix
@@ -3141,7 +3141,7 @@ def handle_c2_async_workout(alldata,userid,c2token,c2id,delaysec,debug=False,**k
# set distance, time
query = "UPDATE `rowers_workout` SET `distance` = '%s', `duration` = '%s' WHERE `id` = '%s'" % (distance, duration, workoutid)
with engine.connect() as conn, conn.begin():
result = conn.execute(query)
@@ -3357,7 +3357,7 @@ def fetch_strava_workout(stravatoken,oauth_data,stravaid,csvfilename,userid,debu
except:
title = ''
starttimeunix = arrow.get(rowdatetime).timestamp
starttimeunix = arrow.get(rowdatetime).timestamp()
res = make_cumvalues(0.1*strokedata['t'])
cum_time = res[0]

View File

@@ -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 #-row.df.ix[0,'TimeStamp (sec)']
# t += arrow.get(st).timestamp
# t += arrow.get(st).timestamp()
# t[0] = t[1]
@@ -405,7 +405,7 @@ def add_workout_from_data(user,importid,data,strokedata,
except:
rowdatetime = datetime.strptime(data['date'],"%Y-%m-%d %H:%M:%S")
rowdatetime = thetimezone.localize(rowdatetime).astimezone(utc)
starttimeunix = arrow.get(rowdatetime).timestamp
starttimeunix = arrow.get(rowdatetime).timestamp()
try:

View File

@@ -2217,8 +2217,8 @@ def rankings_view2(request,userid=0,
lastupdatedtime = arrow.get(lastupdated).timestamp
current_time = arrow.utcnow().timestamp
lastupdatedtime = arrow.get(lastupdated).timestamp()
current_time = arrow.utcnow().timestamp()
deltatime_seconds = current_time - lastupdatedtime
recalc = False

View File

@@ -240,7 +240,7 @@ def workout_csvemail_view(request,id=0):
filename = code+'.csv'
rowdate = rowdata.rowdatetime
starttimeunix = arrow.get(rowdate).timestamp
starttimeunix = arrow.get(rowdate).timestamp()
df = rowdata.df
try:

View File

@@ -1319,7 +1319,7 @@ def add_workout_from_strokedata(user,importid,data,strokedata,
except:
title = ''
starttimeunix = arrow.get(rowdatetime).timestamp
starttimeunix = arrow.get(rowdatetime).timestamp()
res = make_cumvalues(0.1*strokedata['t'])
cum_time = res[0]

View File

@@ -2613,7 +2613,7 @@ def workout_downloadwind_view(request,id=0,
startdatetime = dateutil.parser.parse("{}, {}".format(row.date,
row.starttime))
starttimeunix = int(arrow.get(row.startdatetime).timestamp)
starttimeunix = int(arrow.get(row.startdatetime).timestamp())
#starttimeunix = int(mktime(startdatetime.utctimetuple()))
avgtime = starttimeunix+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,
row.starttime))
starttimeunix = arrow.get(row.startdatetime).timestamp
starttimeunix = arrow.get(row.startdatetime).timestamp()
#starttimeunix = int(mktime(startdatetime.utctimetuple()))
avgtime = starttimeunix +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,workout = dataprep.getrowdata(id=w.id)
datadf = dataprep.dataprep(row.df,id=w.id)