some more improvements
This commit is contained in:
@@ -102,16 +102,15 @@ def getrowdata_db(id=0):
|
|||||||
|
|
||||||
return data,row
|
return data,row
|
||||||
|
|
||||||
def getsmallrowdata_db(xparam,yparam1,yparam2,ids=[]):
|
def getsmallrowdata_db(columns,ids=[]):
|
||||||
if yparam2 == 'None':
|
|
||||||
yparam2 = yparam1
|
|
||||||
prepmultipledata(ids)
|
prepmultipledata(ids)
|
||||||
data = read_cols_df_sql(ids,xparam,yparam1,yparam2)
|
data = read_cols_df_sql(ids,columns)
|
||||||
if xparam == 'time':
|
for column in columns:
|
||||||
|
if column == 'time':
|
||||||
data['time'] = data['time']/1.0e6
|
data['time'] = data['time']/1.0e6
|
||||||
if yparam1 == 'pace':
|
if column == 'pace':
|
||||||
data['pace'] = data['pace']/1.0e6
|
data['pace'] = data['pace']/1.0e6
|
||||||
if yparam2 == 'pace':
|
if column == 'pace':
|
||||||
data['pace'] = data['pace']/1.0e6
|
data['pace'] = data['pace']/1.0e6
|
||||||
|
|
||||||
return data
|
return data
|
||||||
@@ -143,15 +142,17 @@ def prepmultipledata(ids):
|
|||||||
res = list(itertools.chain.from_iterable(res.fetchall()))
|
res = list(itertools.chain.from_iterable(res.fetchall()))
|
||||||
|
|
||||||
res = list(set(ids)-set(res))
|
res = list(set(ids)-set(res))
|
||||||
|
print "aap", res
|
||||||
for id in res:
|
for id in res:
|
||||||
rowdata,row = getrowdata(id=id)
|
rowdata,row = getrowdata(id=id)
|
||||||
if rowdata:
|
if rowdata:
|
||||||
data = dataprep(rowdata.df,id=id,bands=True,barchart=True,otwpower=True)
|
data = dataprep(rowdata.df,id=id,bands=True,barchart=True,otwpower=True)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def read_cols_df_sql(ids,col1,col2,col3):
|
def read_cols_df_sql(ids,columns):
|
||||||
columns = list(set((col1,col2,col3,'distance','spm')))
|
columns = list(columns)+['distance','spm']
|
||||||
|
columns = [x for x in columns if x != 'None']
|
||||||
|
columns = list(set(columns))
|
||||||
cls = ''
|
cls = ''
|
||||||
for column in columns:
|
for column in columns:
|
||||||
cls += column+', '
|
cls += column+', '
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ def interactive_histoall(theworkouts):
|
|||||||
|
|
||||||
ids = [w.id for w in theworkouts]
|
ids = [w.id for w in theworkouts]
|
||||||
|
|
||||||
rowdata = dataprep.getsmallrowdata_db('power','power','power',ids=ids)
|
rowdata = dataprep.getsmallrowdata_db(['power'],ids=ids)
|
||||||
|
|
||||||
histopwr = rowdata['power'].values
|
histopwr = rowdata['power'].values
|
||||||
if len(histopwr) == 0:
|
if len(histopwr) == 0:
|
||||||
@@ -569,7 +569,7 @@ def interactive_cum_flex_chart2(theworkouts,promember=0,
|
|||||||
|
|
||||||
# datadf = dataprep.smalldataprep(theworkouts,xparam,yparam1,yparam2)
|
# datadf = dataprep.smalldataprep(theworkouts,xparam,yparam1,yparam2)
|
||||||
ids = [w.id for w in theworkouts]
|
ids = [w.id for w in theworkouts]
|
||||||
datadf = dataprep.getsmallrowdata_db(xparam,yparam1,yparam2,ids=ids)
|
datadf = dataprep.getsmallrowdata_db([xparam,yparam1,yparam2],ids=ids)
|
||||||
|
|
||||||
axlabels = {
|
axlabels = {
|
||||||
'time': 'Time',
|
'time': 'Time',
|
||||||
|
|||||||
@@ -4457,6 +4457,19 @@ class JSONResponse(HttpResponse):
|
|||||||
super(JSONResponse, self).__init__(content, **kwargs)
|
super(JSONResponse, self).__init__(content, **kwargs)
|
||||||
|
|
||||||
def strokedatajson(request,id):
|
def strokedatajson(request,id):
|
||||||
|
try:
|
||||||
|
row = Workout.objects.get(id=id)
|
||||||
|
if (checkworkoutuser(request.user,row)==False):
|
||||||
|
return HttpResponse("Permission error")
|
||||||
|
except Workout.DoesNotExist:
|
||||||
|
return HttpResponse("Workout doesn't exist")
|
||||||
|
try:
|
||||||
|
id = int(id)
|
||||||
|
except ValueError:
|
||||||
|
return HttpRespone("Not a valid workout number")
|
||||||
|
|
||||||
|
|
||||||
if request.method == 'GET':
|
if request.method == 'GET':
|
||||||
datadf,row = dataprep.getrowdata_db(id=id)
|
columns = ['spm','timesecs','hr','pseconds','power','distance']
|
||||||
|
datadf = dataprep.getsmallrowdata_db(columns,ids=[id])
|
||||||
return JSONResponse(datadf)
|
return JSONResponse(datadf)
|
||||||
|
|||||||
Reference in New Issue
Block a user