Merge branch 'release/v7.32'
This commit is contained in:
+7
-3
@@ -1575,7 +1575,8 @@ def testdata(time, distance, pace, spm):
|
|||||||
# is not in DB, read from CSV file (and create DB entry)
|
# is not in DB, read from CSV file (and create DB entry)
|
||||||
|
|
||||||
|
|
||||||
def getrowdata_db(id=0, doclean=False, convertnewtons=True):
|
def getrowdata_db(id=0, doclean=False, convertnewtons=True,
|
||||||
|
checkefficiency=True):
|
||||||
data = read_df_sql(id)
|
data = read_df_sql(id)
|
||||||
data['x_right'] = data['x_right'] / 1.0e6
|
data['x_right'] = data['x_right'] / 1.0e6
|
||||||
data['deltat'] = data['time'].diff()
|
data['deltat'] = data['time'].diff()
|
||||||
@@ -1591,7 +1592,7 @@ def getrowdata_db(id=0, doclean=False, convertnewtons=True):
|
|||||||
row = Workout.objects.get(id=id)
|
row = Workout.objects.get(id=id)
|
||||||
|
|
||||||
|
|
||||||
if not data.empty and data['efficiency'].mean() == 0 and data['power'].mean() != 0:
|
if not data.empty and data['efficiency'].mean() == 0 and data['power'].mean() != 0 and checkefficiency == True:
|
||||||
data = add_efficiency(id=id)
|
data = add_efficiency(id=id)
|
||||||
|
|
||||||
if doclean:
|
if doclean:
|
||||||
@@ -1946,7 +1947,10 @@ def fix_newtons(id=0, limit=3000):
|
|||||||
|
|
||||||
|
|
||||||
def add_efficiency(id=0):
|
def add_efficiency(id=0):
|
||||||
rowdata, row = getrowdata_db(id=id, doclean=False, convertnewtons=False)
|
rowdata, row = getrowdata_db(id=id,
|
||||||
|
doclean=False,
|
||||||
|
convertnewtons=False,
|
||||||
|
checkefficiency=False)
|
||||||
power = rowdata['power']
|
power = rowdata['power']
|
||||||
pace = rowdata['pace'] / 1.0e3
|
pace = rowdata['pace'] / 1.0e3
|
||||||
velo = 500. / pace
|
velo = 500. / pace
|
||||||
|
|||||||
@@ -631,11 +631,11 @@ def delete_strokedata(id,debug=False):
|
|||||||
conn.close()
|
conn.close()
|
||||||
engine.dispose()
|
engine.dispose()
|
||||||
|
|
||||||
def update_strokedata(id,df,debug=False,bands=True,barchart=True,otwpower=True):
|
def update_strokedata(id,df,debug=False):
|
||||||
delete_strokedata(id,debug=debug)
|
delete_strokedata(id,debug=debug)
|
||||||
if debug:
|
if debug:
|
||||||
print "updating ",id
|
print "updating ",id
|
||||||
rowdata = dataprep(df,id=id,bands=False,barchart=True,otwpower=True,
|
rowdata = dataprep(df,id=id,bands=True,barchart=True,otwpower=True,
|
||||||
debug=debug)
|
debug=debug)
|
||||||
|
|
||||||
return rowdata
|
return rowdata
|
||||||
@@ -1031,8 +1031,6 @@ def dataprep(rowdatadf,id=0,bands=True,barchart=True,otwpower=True,
|
|||||||
velo = 500./p
|
velo = 500./p
|
||||||
|
|
||||||
distanceperstroke = 60.*velo/spm
|
distanceperstroke = 60.*velo/spm
|
||||||
if debug:
|
|
||||||
print distanceperstroke.mean()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1212,8 +1210,6 @@ def dataprep(rowdatadf,id=0,bands=True,barchart=True,otwpower=True,
|
|||||||
ergpace[ergpace == np.inf] = 240.
|
ergpace[ergpace == np.inf] = 240.
|
||||||
ergpace2 = ergpace.apply(lambda x: timedeltaconv(x))
|
ergpace2 = ergpace.apply(lambda x: timedeltaconv(x))
|
||||||
|
|
||||||
efficiency = efficiency.replace([-np.inf,np.inf],np.nan)
|
|
||||||
efficiency.fillna(method='ffill')
|
|
||||||
|
|
||||||
|
|
||||||
data['ergpace'] = ergpace*1e3
|
data['ergpace'] = ergpace*1e3
|
||||||
|
|||||||
@@ -99,19 +99,21 @@ def processattachment(rower, fileobj, title, uploadoptions,testing=False):
|
|||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
if workoutid:
|
if workoutid:
|
||||||
email_sent = send_confirm(
|
if rower.getemailnotifications and not rower.emailbounced:
|
||||||
rower.user, title, link,
|
|
||||||
uploadoptions
|
|
||||||
)
|
|
||||||
time.sleep(10)
|
|
||||||
except:
|
|
||||||
try:
|
|
||||||
time.sleep(10)
|
|
||||||
if workoutid:
|
|
||||||
email_sent = send_confirm(
|
email_sent = send_confirm(
|
||||||
rower.user, title, link,
|
rower.user, title, link,
|
||||||
uploadoptions
|
uploadoptions
|
||||||
)
|
)
|
||||||
|
time.sleep(10)
|
||||||
|
except:
|
||||||
|
try:
|
||||||
|
time.sleep(10)
|
||||||
|
if workoutid:
|
||||||
|
if rower.getemailnotifications and not rower.emailbounced:
|
||||||
|
email_sent = send_confirm(
|
||||||
|
rower.user, title, link,
|
||||||
|
uploadoptions
|
||||||
|
)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
+20
-1
@@ -92,14 +92,33 @@ def get_strava_workouts(rower):
|
|||||||
return 0
|
return 0
|
||||||
else:
|
else:
|
||||||
stravaids = [int(item['id']) for item in res.json()]
|
stravaids = [int(item['id']) for item in res.json()]
|
||||||
|
stravadata = [{
|
||||||
|
'id':int(item['id']),
|
||||||
|
'elapsed_time':item['elapsed_time'],
|
||||||
|
'start_date':item['start_date'],
|
||||||
|
} for item in res.json()]
|
||||||
|
|
||||||
alldata = {}
|
alldata = {}
|
||||||
for item in res.json():
|
for item in res.json():
|
||||||
alldata[item['id']] = item
|
alldata[item['id']] = item
|
||||||
|
|
||||||
|
|
||||||
|
wfailed = Workout.objects.filter(user=rower,uploadedtostrava=-1)
|
||||||
|
|
||||||
|
for w in wfailed:
|
||||||
|
for item in stravadata:
|
||||||
|
elapsed_time = item['elapsed_time']
|
||||||
|
start_date = item['start_date']
|
||||||
|
stravaid = item['id']
|
||||||
|
if arrow.get(start_date) == arrow.get(w.startdatetime):
|
||||||
|
if datetime.time(seconds=int(elapsed_time)) == w.duration:
|
||||||
|
w.uploadedtostrava = int(stravaid)
|
||||||
|
w.save()
|
||||||
|
|
||||||
knownstravaids = uniqify([
|
knownstravaids = uniqify([
|
||||||
w.uploadedtostrava for w in Workout.objects.filter(user=rower)
|
w.uploadedtostrava for w in Workout.objects.filter(user=rower)
|
||||||
])
|
])
|
||||||
|
|
||||||
newids = [stravaid for stravaid in stravaids if not stravaid in knownstravaids]
|
newids = [stravaid for stravaid in stravaids if not stravaid in knownstravaids]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
@@ -9189,6 +9189,25 @@ def workout_stravaimport_view(request,message=""):
|
|||||||
workouts = []
|
workouts = []
|
||||||
r = getrower(request.user)
|
r = getrower(request.user)
|
||||||
stravaids = [int(item['id']) for item in res.json()]
|
stravaids = [int(item['id']) for item in res.json()]
|
||||||
|
stravadata = [{
|
||||||
|
'id':int(item['id']),
|
||||||
|
'elapsed_time':item['elapsed_time'],
|
||||||
|
'start_date':item['start_date'],
|
||||||
|
} for item in res.json()]
|
||||||
|
|
||||||
|
wfailed = Workout.objects.filter(user=r,uploadedtostrava=-1)
|
||||||
|
|
||||||
|
for w in wfailed:
|
||||||
|
for item in stravadata:
|
||||||
|
elapsed_time = item['elapsed_time']
|
||||||
|
start_date = item['start_date']
|
||||||
|
stravaid = item['id']
|
||||||
|
if arrow.get(start_date) == arrow.get(w.startdatetime):
|
||||||
|
if datetime.time(seconds=int(elapsed_time)) == w.duration:
|
||||||
|
w.uploadedtostrava = int(stravaid)
|
||||||
|
w.save()
|
||||||
|
|
||||||
|
|
||||||
knownstravaids = uniqify([
|
knownstravaids = uniqify([
|
||||||
w.uploadedtostrava for w in Workout.objects.filter(user=r)
|
w.uploadedtostrava for w in Workout.objects.filter(user=r)
|
||||||
])
|
])
|
||||||
|
|||||||
Reference in New Issue
Block a user