started with StrokeData POST
This commit is contained in:
@@ -135,16 +135,18 @@ def getrowdata(id=0):
|
|||||||
|
|
||||||
return rowdata,row
|
return rowdata,row
|
||||||
|
|
||||||
def prepmultipledata(ids):
|
|
||||||
|
def prepmultipledata(ids,verbose=False):
|
||||||
query = sa.text('SELECT DISTINCT workoutid FROM strokedata')
|
query = sa.text('SELECT DISTINCT workoutid FROM strokedata')
|
||||||
with engine.connect() as conn, conn.begin():
|
with engine.connect() as conn, conn.begin():
|
||||||
res = conn.execute(query)
|
res = conn.execute(query)
|
||||||
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 verbose:
|
||||||
|
print 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
|
||||||
|
|||||||
@@ -40,5 +40,16 @@ class WorkoutSerializer(serializers.HyperlinkedModelSerializer):
|
|||||||
'csvfilename',
|
'csvfilename',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
class StrokeDataSerielizer(serializers.Serializer):
|
||||||
|
workoutid = serializers.IntegerField
|
||||||
|
strokedata = serializers.JSONField
|
||||||
|
|
||||||
|
def create(self, validated_data):
|
||||||
|
"""
|
||||||
|
Create and enter a new set of stroke data into the DB
|
||||||
|
"""
|
||||||
|
|
||||||
|
# do something
|
||||||
|
print "fake serializer"
|
||||||
|
return 1
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ urlpatterns = [
|
|||||||
url(r'^', include(router.urls)),
|
url(r'^', include(router.urls)),
|
||||||
url(r'^api-docs$', views.schema_view),
|
url(r'^api-docs$', views.schema_view),
|
||||||
url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')),
|
url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')),
|
||||||
url(r'^api/(\d+)/strokedata$',views.strokedatajson),
|
url(r'^api/workouts/(\d+)/strokedata$',views.strokedatajson),
|
||||||
url(r'^testbokeh$',views.testbokeh),
|
url(r'^testbokeh$',views.testbokeh),
|
||||||
url(r'^500/$', TemplateView.as_view(template_name='500.html'),name='500'),
|
url(r'^500/$', TemplateView.as_view(template_name='500.html'),name='500'),
|
||||||
url(r'^404/$', TemplateView.as_view(template_name='404.html'),name='404'),
|
url(r'^404/$', TemplateView.as_view(template_name='404.html'),name='404'),
|
||||||
|
|||||||
@@ -4467,10 +4467,19 @@ def strokedatajson(request,id):
|
|||||||
try:
|
try:
|
||||||
id = int(id)
|
id = int(id)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return HttpRespone("Not a valid workout number")
|
return HttpResponse("Not a valid workout number")
|
||||||
|
|
||||||
|
|
||||||
if request.method == 'GET':
|
if request.method == 'GET':
|
||||||
columns = ['spm','timesecs','hr','pseconds','power','distance']
|
columns = ['spm','timesecs','hr','pseconds','power','distance']
|
||||||
datadf = dataprep.getsmallrowdata_db(columns,ids=[id])
|
datadf = dataprep.getsmallrowdata_db(columns,ids=[id])
|
||||||
return JSONResponse(datadf)
|
return JSONResponse(datadf)
|
||||||
|
|
||||||
|
if request.method == 'POST':
|
||||||
|
strokedata = request.POST['strokedata']
|
||||||
|
# checking/validating and cleaning
|
||||||
|
|
||||||
|
# mangling
|
||||||
|
|
||||||
|
#
|
||||||
|
return HttpResponse("OK")
|
||||||
|
|||||||
Reference in New Issue
Block a user