Private
Public Access
1
0

started with StrokeData POST

This commit is contained in:
Sander Roosendaal
2016-11-25 15:27:46 +01:00
parent 44b2145f2f
commit af3396cfee
4 changed files with 27 additions and 5 deletions

View File

@@ -135,16 +135,18 @@ def getrowdata(id=0):
return rowdata,row
def prepmultipledata(ids):
def prepmultipledata(ids,verbose=False):
query = sa.text('SELECT DISTINCT workoutid FROM strokedata')
with engine.connect() as conn, conn.begin():
res = conn.execute(query)
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 verbose:
print id
if rowdata:
data = dataprep(rowdata.df,id=id,bands=True,barchart=True,otwpower=True)
return res

View File

@@ -40,5 +40,16 @@ class WorkoutSerializer(serializers.HyperlinkedModelSerializer):
'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

View File

@@ -40,7 +40,7 @@ urlpatterns = [
url(r'^', include(router.urls)),
url(r'^api-docs$', views.schema_view),
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'^500/$', TemplateView.as_view(template_name='500.html'),name='500'),
url(r'^404/$', TemplateView.as_view(template_name='404.html'),name='404'),

View File

@@ -4467,10 +4467,19 @@ def strokedatajson(request,id):
try:
id = int(id)
except ValueError:
return HttpRespone("Not a valid workout number")
return HttpResponse("Not a valid workout number")
if request.method == 'GET':
columns = ['spm','timesecs','hr','pseconds','power','distance']
datadf = dataprep.getsmallrowdata_db(columns,ids=[id])
return JSONResponse(datadf)
if request.method == 'POST':
strokedata = request.POST['strokedata']
# checking/validating and cleaning
# mangling
#
return HttpResponse("OK")