ordering in mysql
This commit is contained in:
@@ -1911,12 +1911,12 @@ def read_cols_df_sql(ids, columns, convertnewtons=True):
|
||||
# columns=cls,
|
||||
# ))
|
||||
elif len(ids) == 1:
|
||||
query = sa.text('SELECT {columns} FROM strokedata WHERE workoutid={id}'.format(
|
||||
query = sa.text('SELECT {columns} FROM strokedata WHERE workoutid={id} ORDER BY time ASC'.format(
|
||||
id=ids[0],
|
||||
columns=cls,
|
||||
))
|
||||
else:
|
||||
query = sa.text('SELECT {columns} FROM strokedata WHERE workoutid IN {ids}'.format(
|
||||
query = sa.text('SELECT {columns} FROM strokedata WHERE workoutid IN {ids} ORDER BY time ASC'.format(
|
||||
columns=cls,
|
||||
ids=tuple(ids),
|
||||
))
|
||||
@@ -1953,7 +1953,7 @@ def read_cols_df_sql(ids, columns, convertnewtons=True):
|
||||
def read_df_sql(id):
|
||||
engine = create_engine(database_url, echo=False)
|
||||
|
||||
df = pd.read_sql_query(sa.text('SELECT * FROM strokedata WHERE workoutid={id}'.format(
|
||||
df = pd.read_sql_query(sa.text('SELECT * FROM strokedata WHERE workoutid={id} ORDER BY time ASC'.format(
|
||||
id=id)), engine)
|
||||
|
||||
engine.dispose()
|
||||
|
||||
@@ -2699,11 +2699,11 @@ def interactive_chart(id=0,promember=0,intervaldata = {}):
|
||||
row = Workout.objects.get(id=id)
|
||||
if datadf.empty:
|
||||
return "","No Valid Data Available"
|
||||
else:
|
||||
try:
|
||||
datadf.sort_values(by='time',ascending=True,inplace=True)
|
||||
except KeyError:
|
||||
return "","No valid data available"
|
||||
#else:
|
||||
# try:
|
||||
# datadf.sort_values(by='time',ascending=True,inplace=True)
|
||||
# except KeyError:
|
||||
# return "","No valid data available"
|
||||
|
||||
try:
|
||||
spm = datadf['spm']
|
||||
@@ -2715,10 +2715,6 @@ def interactive_chart(id=0,promember=0,intervaldata = {}):
|
||||
except KeyError:
|
||||
datadf['pace'] = 0
|
||||
|
||||
#datadf,row = dataprep.getrowdata_db(id=id)
|
||||
#if datadf.empty:
|
||||
#return "","No Valid Data Available"
|
||||
|
||||
source = ColumnDataSource(
|
||||
datadf
|
||||
)
|
||||
@@ -3526,11 +3522,11 @@ def interactive_flex_chart2(id=0,promember=0,
|
||||
row = Workout.objects.get(id=id)
|
||||
if rowdata.empty:
|
||||
return "","No valid data",'','',workstrokesonly
|
||||
else:
|
||||
try:
|
||||
rowdata.sort_values(by='time',ascending=True,inplace=True)
|
||||
except KeyError:
|
||||
pass
|
||||
#else:
|
||||
# try:
|
||||
# rowdata.sort_values(by='time',ascending=True,inplace=True)
|
||||
# except KeyError:
|
||||
# pass
|
||||
|
||||
workoutstateswork = [1,4,5,8,9,6,7]
|
||||
workoutstatesrest = [3]
|
||||
@@ -4094,11 +4090,11 @@ def thumbnails_set(r,id,favorites):
|
||||
'notes':""
|
||||
}]
|
||||
|
||||
else:
|
||||
try:
|
||||
rowdata.sort_values(by='time',ascending=True,inplace=True)
|
||||
except KeyError:
|
||||
pass
|
||||
# else:
|
||||
# try:
|
||||
# rowdata.sort_values(by='time',ascending=True,inplace=True)
|
||||
# except KeyError:
|
||||
# pass
|
||||
|
||||
l = len(rowdata)
|
||||
maxlength = 50
|
||||
@@ -4673,13 +4669,13 @@ def interactive_comparison_chart(id1=0,id2=0,xparam='distance',yparam='spm',
|
||||
|
||||
if rowdata1.empty:
|
||||
return "","No Valid Data Available"
|
||||
else:
|
||||
rowdata1.sort_values(by='time',ascending=True,inplace=True)
|
||||
# else:
|
||||
# rowdata1.sort_values(by='time',ascending=True,inplace=True)
|
||||
|
||||
if rowdata2.empty:
|
||||
return "","No Valid Data Available"
|
||||
else:
|
||||
rowdata2.sort_values(by='time',ascending=True,inplace=True)
|
||||
# else:
|
||||
# rowdata2.sort_values(by='time',ascending=True,inplace=True)
|
||||
|
||||
try:
|
||||
x1 = rowdata1.loc[:,xparam]
|
||||
|
||||
Reference in New Issue
Block a user