Private
Public Access
1
0
This commit is contained in:
Sander Roosendaal
2022-07-18 19:40:47 +02:00
parent d799de2cd2
commit b557de73a2
10 changed files with 2351 additions and 1989 deletions

View File

@@ -14,7 +14,8 @@ from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
from rowers.models import (
Workout, GeoPolygon, GeoPoint, GeoCourse,
VirtualRaceResult, CourseTestResult, Rower
VirtualRaceResult, CourseTestResult, Rower,
GraphImage,
)
import math
@@ -45,6 +46,7 @@ import re
import sys
import json
import traceback
from time import strftime
from scipy import optimize
from scipy.signal import savgol_filter
@@ -103,7 +105,7 @@ from rowers.emails import htmlstrip
from rowers import mytypes
from rowers.dataprep import (
from rowers.dataroutines import (
getsmallrowdata_db, updatecpdata_sql, update_c2id_sql,
#update_workout_field_sql,
update_agegroup_db, update_strokedata,
@@ -297,6 +299,42 @@ def summaryfromsplitdata(splitdata, data, filename, sep='|', workouttype='rower'
return sums, sa, results
@app.task
def instroke_static(w, metric, debug=False, **kwargs):
f1 = w.csvfilename[6:-4]
rowdata = rdata(csvfile=w.csvfilename)
timestr = strftime("%Y%m%d-%H%M%S")
imagename = f1+timestr+'.png'
fullpathimagename = 'static/plots/'+imagename
r = w.user
fig1 = rowdata.get_plot_instroke(metric)
canvas = FigureCanvas(fig1)
canvas.print_figure('static/plots/'+imagename)
plt.close(fig1)
fig1.clf()
try:
width, height = Image.open(fullpathimagename).size
except:
width = 1200
height = 600
imgs = GraphImage.objects.filter(workout=w)
if imgs.count() < 7:
i = GraphImage(workout=w,
creationdatetime=timezone.now(),
filename=fullpathimagename,
width=width, height=height)
i.save()
else:
return 0
return 1
@app.task
def handle_request_post(url, data, debug=False, **kwargs): # pragma: no cover