some more improvements
This commit is contained in:
@@ -102,16 +102,15 @@ def getrowdata_db(id=0):
|
||||
|
||||
return data,row
|
||||
|
||||
def getsmallrowdata_db(xparam,yparam1,yparam2,ids=[]):
|
||||
if yparam2 == 'None':
|
||||
yparam2 = yparam1
|
||||
def getsmallrowdata_db(columns,ids=[]):
|
||||
prepmultipledata(ids)
|
||||
data = read_cols_df_sql(ids,xparam,yparam1,yparam2)
|
||||
if xparam == 'time':
|
||||
data = read_cols_df_sql(ids,columns)
|
||||
for column in columns:
|
||||
if column == 'time':
|
||||
data['time'] = data['time']/1.0e6
|
||||
if yparam1 == 'pace':
|
||||
if column == 'pace':
|
||||
data['pace'] = data['pace']/1.0e6
|
||||
if yparam2 == 'pace':
|
||||
if column == 'pace':
|
||||
data['pace'] = data['pace']/1.0e6
|
||||
|
||||
return data
|
||||
@@ -143,15 +142,17 @@ def prepmultipledata(ids):
|
||||
res = list(itertools.chain.from_iterable(res.fetchall()))
|
||||
|
||||
res = list(set(ids)-set(res))
|
||||
|
||||
print "aap", res
|
||||
for id in res:
|
||||
rowdata,row = getrowdata(id=id)
|
||||
if rowdata:
|
||||
data = dataprep(rowdata.df,id=id,bands=True,barchart=True,otwpower=True)
|
||||
return res
|
||||
|
||||
def read_cols_df_sql(ids,col1,col2,col3):
|
||||
columns = list(set((col1,col2,col3,'distance','spm')))
|
||||
def read_cols_df_sql(ids,columns):
|
||||
columns = list(columns)+['distance','spm']
|
||||
columns = [x for x in columns if x != 'None']
|
||||
columns = list(set(columns))
|
||||
cls = ''
|
||||
for column in columns:
|
||||
cls += column+', '
|
||||
|
||||
@@ -72,7 +72,7 @@ def interactive_histoall(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
|
||||
if len(histopwr) == 0:
|
||||
@@ -569,7 +569,7 @@ def interactive_cum_flex_chart2(theworkouts,promember=0,
|
||||
|
||||
# datadf = dataprep.smalldataprep(theworkouts,xparam,yparam1,yparam2)
|
||||
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 = {
|
||||
'time': 'Time',
|
||||
|
||||
@@ -4457,6 +4457,19 @@ class JSONResponse(HttpResponse):
|
||||
super(JSONResponse, self).__init__(content, **kwargs)
|
||||
|
||||
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':
|
||||
datadf,row = dataprep.getrowdata_db(id=id)
|
||||
columns = ['spm','timesecs','hr','pseconds','power','distance']
|
||||
datadf = dataprep.getsmallrowdata_db(columns,ids=[id])
|
||||
return JSONResponse(datadf)
|
||||
|
||||
Reference in New Issue
Block a user