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)
|
||||
|
||||
|
||||
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['x_right'] = data['x_right'] / 1.0e6
|
||||
data['deltat'] = data['time'].diff()
|
||||
@@ -1591,7 +1592,7 @@ def getrowdata_db(id=0, doclean=False, convertnewtons=True):
|
||||
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)
|
||||
|
||||
if doclean:
|
||||
@@ -1946,7 +1947,10 @@ def fix_newtons(id=0, limit=3000):
|
||||
|
||||
|
||||
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']
|
||||
pace = rowdata['pace'] / 1.0e3
|
||||
velo = 500. / pace
|
||||
|
||||
@@ -631,11 +631,11 @@ def delete_strokedata(id,debug=False):
|
||||
conn.close()
|
||||
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)
|
||||
if debug:
|
||||
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)
|
||||
|
||||
return rowdata
|
||||
@@ -1031,8 +1031,6 @@ def dataprep(rowdatadf,id=0,bands=True,barchart=True,otwpower=True,
|
||||
velo = 500./p
|
||||
|
||||
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.
|
||||
ergpace2 = ergpace.apply(lambda x: timedeltaconv(x))
|
||||
|
||||
efficiency = efficiency.replace([-np.inf,np.inf],np.nan)
|
||||
efficiency.fillna(method='ffill')
|
||||
|
||||
|
||||
data['ergpace'] = ergpace*1e3
|
||||
|
||||
@@ -99,6 +99,7 @@ def processattachment(rower, fileobj, title, uploadoptions,testing=False):
|
||||
)
|
||||
try:
|
||||
if workoutid:
|
||||
if rower.getemailnotifications and not rower.emailbounced:
|
||||
email_sent = send_confirm(
|
||||
rower.user, title, link,
|
||||
uploadoptions
|
||||
@@ -108,6 +109,7 @@ def processattachment(rower, fileobj, title, uploadoptions,testing=False):
|
||||
try:
|
||||
time.sleep(10)
|
||||
if workoutid:
|
||||
if rower.getemailnotifications and not rower.emailbounced:
|
||||
email_sent = send_confirm(
|
||||
rower.user, title, link,
|
||||
uploadoptions
|
||||
|
||||
@@ -92,14 +92,33 @@ def get_strava_workouts(rower):
|
||||
return 0
|
||||
else:
|
||||
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 = {}
|
||||
for item in res.json():
|
||||
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([
|
||||
w.uploadedtostrava for w in Workout.objects.filter(user=rower)
|
||||
])
|
||||
|
||||
newids = [stravaid for stravaid in stravaids if not stravaid in knownstravaids]
|
||||
|
||||
|
||||
|
||||
@@ -9189,6 +9189,25 @@ def workout_stravaimport_view(request,message=""):
|
||||
workouts = []
|
||||
r = getrower(request.user)
|
||||
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([
|
||||
w.uploadedtostrava for w in Workout.objects.filter(user=r)
|
||||
])
|
||||
|
||||
Reference in New Issue
Block a user