submission and show result fastest challenges
This commit is contained in:
@@ -452,7 +452,7 @@ def getfastest(df,thevalue,mode='distance'):
|
||||
starttime = griddata(restime,starttimes,[thevalue*60*1000],method='linear',rescale=True)
|
||||
duration = griddata(restime,restime,[thevalue*60*1000],method='linear',rescale=True)
|
||||
endtime = starttime+duration
|
||||
#print(distance,starttime,endtime )
|
||||
print(distance,starttime,endtime )
|
||||
return distance[0],starttime[0]/1000.,endtime[0]/1000.
|
||||
|
||||
return 0
|
||||
|
||||
@@ -371,7 +371,7 @@ def add_workouts_plannedsession(ws,ps,r):
|
||||
ids = [w.id for w in wold] + [w.id for w in ws]
|
||||
ids = list(set(ids))
|
||||
|
||||
if len(ids)>1 and ps.sessiontype in ['test','coursetest','race','fastest_distance','fastest_time']:
|
||||
if len(ids)>1 and ps.sessiontype in ['test','coursetest','race']:
|
||||
errors.append('For tests, you can only attach one workout')
|
||||
return result,comments,errors
|
||||
|
||||
@@ -1571,19 +1571,6 @@ def add_workout_fastestrace(ws, race, r, recordid=0, doregister=False):
|
||||
enddatetime
|
||||
)
|
||||
|
||||
# check if all sessions have same date
|
||||
dates = [w.date for w in ws]
|
||||
if (not all(d == dates[0] for d in dates)) and race.sessiontype not in ['challenge','cycletarget']:
|
||||
errors.append('For tests and training sessions, selected workouts must all be done on the same date')
|
||||
return result,comments,errors,0
|
||||
|
||||
|
||||
if len(ws)>1 and race.sessiontype == 'test':
|
||||
errors.append('For tests, you can only attach one workout')
|
||||
return result,comments,errors,0
|
||||
|
||||
|
||||
|
||||
ids = [w.id for w in ws]
|
||||
ids = list(set(ids))
|
||||
|
||||
@@ -1671,7 +1658,7 @@ def add_workout_fastestrace(ws, race, r, recordid=0, doregister=False):
|
||||
record.workoutid = ws[0].id
|
||||
if race.sessiontype == 'fastest_distance':
|
||||
df = dataprep.getsmallrowdata_db(['time','cumdist'],ids=[ws[0].id])
|
||||
fastest_milliseconds = datautils.getfastest(df,race.sessionvalue,mode='distance')
|
||||
fastest_milliseconds,startsecond,endsecond = datautils.getfastest(df,race.sessionvalue,mode='distance')
|
||||
velo = race.sessionvalue/fastest_milliseconds
|
||||
points = 100.*velo/record.referencespeed
|
||||
|
||||
@@ -1681,10 +1668,12 @@ def add_workout_fastestrace(ws, race, r, recordid=0, doregister=False):
|
||||
record.duration = duration
|
||||
record.distance = race.sessionvalue
|
||||
record.points = points
|
||||
record.startsecond = startsecond
|
||||
record.endsecond = endsecond
|
||||
record.save()
|
||||
if race.sessiontype == 'fastest_time':
|
||||
df = dataprep.getsmallrowdata_db(['time','cumdist'],ids=[ws[0].id])
|
||||
fastest_meters = datautils.getfastest(df,race.sessionvalue,mode='time')
|
||||
fastest_meters, startsecond, endsecond = datautils.getfastest(df,race.sessionvalue,mode='time')
|
||||
velo = fastest_meters/(60.*race.sessionvalue)
|
||||
points = 100.*velo/record.referencespeed
|
||||
|
||||
@@ -1694,6 +1683,8 @@ def add_workout_fastestrace(ws, race, r, recordid=0, doregister=False):
|
||||
record.distance = fastest_meters
|
||||
record.coursecompleted = True
|
||||
record.points = points
|
||||
record.startsecond = startsecond
|
||||
record.endsecond = endsecond
|
||||
record.save()
|
||||
|
||||
|
||||
|
||||
@@ -322,8 +322,19 @@
|
||||
<tr>
|
||||
<td>{{ forloop.counter }}</td>
|
||||
<td>
|
||||
{% if race.sessiontype == 'race' %}
|
||||
<a href="/rowers/workout/{{ result.workoutid|encode }}/view/entry/{{ result.id }}/">
|
||||
{{ result.username }}</a></td>
|
||||
{{ result.username }}</a>
|
||||
{% elif race.sessiontype == 'fastest_time' %}
|
||||
<a href="/rowers/workout/{{ result.workoutid|encode }}/view/entry/{{ result.id }}/nocourse/">
|
||||
{{ result.username }}</a>
|
||||
{% elif race.sessiontype == 'fastest_distance' %}
|
||||
<a href="/rowers/workout/{{ result.workoutid|encode }}/view/entry/{{ result.id }}/nocourse/">
|
||||
{{ result.username }}</a>
|
||||
{% else %}
|
||||
{{ result.username }}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>{{ result.teamname }}</td>
|
||||
{% if race.coursestandards %}
|
||||
<td>{{ result.entrycategory }}</td>
|
||||
|
||||
@@ -458,6 +458,7 @@ urlpatterns = [
|
||||
re_path(r'^workout/(?P<id>\b[0-9A-Fa-f]+\b)/split/$',views.workout_split_view,name='workout_split_view'),
|
||||
# re_path(r'^workout/(?P<id>\d+)/interactiveplot/$',views.workout_biginteractive_view),
|
||||
re_path(r'^workout/(?P<id>\b[0-9A-Fa-f]+\b)/view/entry/(?P<raceresult>\d+)/$',views.workout_view,name='workout_view'),
|
||||
re_path(r'^workout/(?P<id>\b[0-9A-Fa-f]+\b)/view/entry/(?P<nocourseraceresult>\d+)/nocourse/$',views.workout_view,name='workout_view'),
|
||||
re_path(r'^workout/(?P<id>\b[0-9A-Fa-f]+\b)/view/session/(?P<sessionresult>\d+)/$',views.workout_view,name='workout_view'),
|
||||
re_path(r'^workout/(?P<id>\b[0-9A-Fa-f]+\b)/view/$',views.workout_view,name='workout_view'),
|
||||
re_path(r'^workout/(?P<id>\b[0-9A-Fa-f]+\b)/video/$',views.workout_video_create_view,
|
||||
|
||||
@@ -2323,7 +2323,7 @@ def workout_fusion_list(request,id=0,
|
||||
|
||||
# Basic view of workout
|
||||
@permission_required('workout.view_workout',fn=get_workout_by_opaqueid,raise_exception=True)
|
||||
def workout_view(request,id=0,raceresult=0,sessionresult=0):
|
||||
def workout_view(request,id=0,raceresult=0,sessionresult=0,nocourseraceresult=0):
|
||||
request.session['referer'] = absolute(request)['PATH']
|
||||
|
||||
if not request.user.is_anonymous:
|
||||
@@ -2373,6 +2373,26 @@ def workout_view(request,id=0,raceresult=0,sessionresult=0):
|
||||
except CourseTestResult.DoesNotExist:
|
||||
pass
|
||||
|
||||
if nocourseraceresult != 0:
|
||||
try:
|
||||
result = IndoorVirtualRaceResult.objects.get(id=nocourseraceresult)
|
||||
startsecond = result.startsecond
|
||||
endsecond = result.endsecond
|
||||
duration = row.duration
|
||||
durationsecs = duration.hour*3600+duration.minute*60+duration.second
|
||||
itime = [startsecond,endsecond-startsecond]
|
||||
itype = [3,4]
|
||||
intervaldata['itime'] = itime
|
||||
intervaldata['itype'] = itype
|
||||
|
||||
rowdata.updateinterval_metric(' AverageBoatSpeed (m/s)',0.1,mode='larger',
|
||||
debug=False,smoothwindow=15.,
|
||||
activewindow = [startsecond,endsecond])
|
||||
summary = rowdata.allstats()
|
||||
except CourseTestResult.DoesNotExist:
|
||||
pass
|
||||
|
||||
|
||||
if raceresult != 0:
|
||||
try:
|
||||
result = VirtualRaceResult.objects.get(id=raceresult)
|
||||
|
||||
Reference in New Issue
Block a user