v0.1 of testcourse working (plannedsession)
This commit is contained in:
@@ -120,7 +120,7 @@ def time_in_path(df,p,maxmin='max'):
|
|||||||
b = (~df['inpolygon']).shift(1)+df['inpolygon']
|
b = (~df['inpolygon']).shift(1)+df['inpolygon']
|
||||||
|
|
||||||
if len(df[b==2]):
|
if len(df[b==2]):
|
||||||
return df[b==2]['time'].min()
|
return df[b==2]['time'].min(),df[b==2]['cum_dist'].min()
|
||||||
|
|
||||||
raise InvalidTrajectoryError("Trajectory doesn't go through path")
|
raise InvalidTrajectoryError("Trajectory doesn't go through path")
|
||||||
|
|
||||||
@@ -230,19 +230,22 @@ def createcourse(
|
|||||||
def coursetime_first(data,paths):
|
def coursetime_first(data,paths):
|
||||||
|
|
||||||
entrytime = data['time'].max()
|
entrytime = data['time'].max()
|
||||||
|
entrydistance = data['cum_dist'].max()
|
||||||
coursecompleted = False
|
coursecompleted = False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
entrytime = time_in_path(data,paths[0],maxmin='max')
|
entrytime,entrydistance = time_in_path(data,paths[0],maxmin='max')
|
||||||
coursecompleted = True
|
coursecompleted = True
|
||||||
except InvalidTrajectoryError:
|
except InvalidTrajectoryError:
|
||||||
entrytime = data['time'].max()
|
entrytime = data['time'].max()
|
||||||
|
entrydistance = data['cum_dist'].max()
|
||||||
coursecompleted = False
|
coursecompleted = False
|
||||||
return entrytime, coursecompleted
|
return entrytime, entrydistance, coursecompleted
|
||||||
|
|
||||||
def coursetime_paths(data,paths,finalmaxmin='min'):
|
def coursetime_paths(data,paths,finalmaxmin='min'):
|
||||||
|
|
||||||
entrytime = data['time'].max()
|
entrytime = data['time'].max()
|
||||||
|
entrydistance = data['cum_dist'].max()
|
||||||
coursecompleted = False
|
coursecompleted = False
|
||||||
|
|
||||||
# corner case - empty list of paths
|
# corner case - empty list of paths
|
||||||
@@ -252,32 +255,42 @@ def coursetime_paths(data,paths,finalmaxmin='min'):
|
|||||||
# end - just the Finish polygon
|
# end - just the Finish polygon
|
||||||
if len(paths) == 1:
|
if len(paths) == 1:
|
||||||
try:
|
try:
|
||||||
entrytime = time_in_path(data,paths[0],maxmin=finalmaxmin)
|
(
|
||||||
|
entrytime,
|
||||||
|
entrydistance
|
||||||
|
) = time_in_path(data,paths[0],maxmin=finalmaxmin)
|
||||||
coursecompleted = True
|
coursecompleted = True
|
||||||
except InvalidTrajectoryError:
|
except InvalidTrajectoryError:
|
||||||
entrytime = data['time'].max()
|
entrytime = data['time'].max()
|
||||||
|
entrydistance = data['cum_dist'].max()
|
||||||
coursecompleted = False
|
coursecompleted = False
|
||||||
return entrytime,coursecompleted
|
return entrytime,entrydistance,coursecompleted
|
||||||
|
|
||||||
if len(paths) > 1:
|
if len(paths) > 1:
|
||||||
try:
|
try:
|
||||||
time = time_in_path(data, paths[0])
|
time,dist = time_in_path(data, paths[0])
|
||||||
data = data[data['time']>time]
|
data = data[data['time']>time]
|
||||||
data['time'] = data['time']-time
|
data['time'] = data['time']-time
|
||||||
timenext, coursecompleted = coursetime_paths(data,paths[1:])
|
data['cum_dist'] = data['cum_dist']-dist
|
||||||
return time+timenext, coursecompleted
|
(
|
||||||
|
timenext,
|
||||||
|
distnext,
|
||||||
|
coursecompleted
|
||||||
|
) = coursetime_paths(data,paths[1:])
|
||||||
|
return time+timenext, dist+distnext,coursecompleted
|
||||||
except InvalidTrajectoryError:
|
except InvalidTrajectoryError:
|
||||||
entrytime = data['time'].max()
|
entrytime = data['time'].max()
|
||||||
|
entrydistance = data['cum_dist'].max()
|
||||||
coursecompleted = False
|
coursecompleted = False
|
||||||
|
|
||||||
return entrytime, coursecompleted
|
return entrytime, entrydistance, coursecompleted
|
||||||
|
|
||||||
def get_time_course(ws,course):
|
def get_time_course(ws,course):
|
||||||
coursetimeseconds = 0.0
|
coursetimeseconds = 0.0
|
||||||
coursecompleted = 0
|
coursecompleted = 0
|
||||||
|
|
||||||
w = ws[0]
|
w = ws[0]
|
||||||
columns = ['time',' latitude',' longitude']
|
columns = ['time',' latitude',' longitude','cum_dist']
|
||||||
rowdata = dataprep.getsmallrowdata_db(
|
rowdata = dataprep.getsmallrowdata_db(
|
||||||
columns,
|
columns,
|
||||||
ids = [w.id],
|
ids = [w.id],
|
||||||
@@ -303,10 +316,20 @@ def get_time_course(ws,course):
|
|||||||
path = polygon_to_path(polygon)
|
path = polygon_to_path(polygon)
|
||||||
paths.append(path)
|
paths.append(path)
|
||||||
|
|
||||||
coursetimeseconds,coursecompleted = coursetime_paths(rowdata,paths)
|
(
|
||||||
coursetimefirst,firstcompleted = coursetime_first(
|
coursetimeseconds,
|
||||||
|
coursemeters,
|
||||||
|
coursecompleted,
|
||||||
|
|
||||||
|
) = coursetime_paths(rowdata,paths)
|
||||||
|
(
|
||||||
|
coursetimefirst,
|
||||||
|
coursemetersfirst,
|
||||||
|
firstcompleted
|
||||||
|
) = coursetime_first(
|
||||||
rowdata,paths)
|
rowdata,paths)
|
||||||
|
|
||||||
coursetimeseconds = coursetimeseconds-coursetimefirst
|
coursetimeseconds = coursetimeseconds-coursetimefirst
|
||||||
|
coursemeters = coursemeters-coursemetersfirst
|
||||||
|
|
||||||
return coursetimeseconds,coursecompleted
|
return coursetimeseconds,coursemeters,coursecompleted
|
||||||
|
|||||||
@@ -238,7 +238,11 @@ def is_session_complete_ws(ws,ps):
|
|||||||
return ratio,'partial',completiondate
|
return ratio,'partial',completiondate
|
||||||
elif ps.sessiontype == 'coursetest':
|
elif ps.sessiontype == 'coursetest':
|
||||||
if ps.course:
|
if ps.course:
|
||||||
coursetime,coursecompleted = courses.get_time_course(ws,ps.course)
|
(
|
||||||
|
coursetime,
|
||||||
|
coursemeters,
|
||||||
|
coursecompleted
|
||||||
|
) = courses.get_time_course(ws,ps.course)
|
||||||
if coursecompleted:
|
if coursecompleted:
|
||||||
return 1.0,'completed',completiondate
|
return 1.0,'completed',completiondate
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -65,7 +65,7 @@
|
|||||||
<td>{{ forloop.counter }}</td>
|
<td>{{ forloop.counter }}</td>
|
||||||
<td>{{ result|lookup:'name' }}</td>
|
<td>{{ result|lookup:'name' }}</td>
|
||||||
<td>{{ result|lookup:'distance' }}</td>
|
<td>{{ result|lookup:'distance' }}</td>
|
||||||
<td>{{ result|lookup:'time'|durationprint:"%H:%M:%S.%f" }}</td>
|
<td>{{ result|lookup:'time'|deltatimeprint }}</td>
|
||||||
<td>{{ result|lookup:'date'|date:"Y-m-d" }}</td>
|
<td>{{ result|lookup:'date'|date:"Y-m-d" }}</td>
|
||||||
<td>{{ result|lookup:'type' }}</td>
|
<td>{{ result|lookup:'type' }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@@ -12657,15 +12657,24 @@ def plannedsession_view(request,id=0,rowerid=0,
|
|||||||
rankws = Workout.objects.filter(
|
rankws = Workout.objects.filter(
|
||||||
plannedsession=ps).order_by("-distance")
|
plannedsession=ps).order_by("-distance")
|
||||||
for w in rankws:
|
for w in rankws:
|
||||||
|
dd = w.duration
|
||||||
|
dddelta = datetime.timedelta(hours=dd.hour,
|
||||||
|
minutes=dd.minute,
|
||||||
|
seconds=dd.second,
|
||||||
|
microseconds=dd.microsecond)
|
||||||
wdict = {
|
wdict = {
|
||||||
'name': w.user.user.first_name+' '+w.user.user.last_name,
|
'name': w.user.user.first_name+' '+w.user.user.last_name,
|
||||||
'date': w.date,
|
'date': w.date,
|
||||||
'distance': w.distance,
|
'distance': w.distance,
|
||||||
'time': w.duration,
|
'time': dddelta,
|
||||||
'type': w.workouttype,
|
'type': w.workouttype,
|
||||||
}
|
}
|
||||||
if ps.sessiontype == 'coursetest':
|
if ps.sessiontype == 'coursetest':
|
||||||
coursetimeseconds,coursecompleted = courses.get_time_course(ws,ps.course)
|
(
|
||||||
|
coursetimeseconds,
|
||||||
|
coursemeters,
|
||||||
|
coursecompleted
|
||||||
|
) = courses.get_time_course(ws,ps.course)
|
||||||
intsecs = int(coursetimeseconds)
|
intsecs = int(coursetimeseconds)
|
||||||
microsecs = int(1.e6*(coursetimeseconds-intsecs))
|
microsecs = int(1.e6*(coursetimeseconds-intsecs))
|
||||||
|
|
||||||
@@ -12673,9 +12682,12 @@ def plannedsession_view(request,id=0,rowerid=0,
|
|||||||
seconds=intsecs,
|
seconds=intsecs,
|
||||||
microseconds=microsecs
|
microseconds=microsecs
|
||||||
)
|
)
|
||||||
|
wdict['distance'] = int(round(coursemeters))
|
||||||
|
|
||||||
|
|
||||||
ranking.append(wdict)
|
ranking.append(wdict)
|
||||||
|
if ps.sessiontype == 'coursetest':
|
||||||
|
ranking = sorted(ranking, key=lambda k: k['time'])
|
||||||
|
|
||||||
# if coursetest, need to reorder the ranking
|
# if coursetest, need to reorder the ranking
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ handler500 = 'rowers.views.error500_view'
|
|||||||
|
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
|
url(r'^admin/jsi18n', 'django.views.i18n.javascript_catalog'),
|
||||||
url(r'^django-rq/',include('django_rq.urls')),
|
url(r'^django-rq/',include('django_rq.urls')),
|
||||||
url(r'^password_change_done/$',auth_views.password_change_done,name='password_change_done'),
|
url(r'^password_change_done/$',auth_views.password_change_done,name='password_change_done'),
|
||||||
url(r'^password_change/$',auth_views.password_change),
|
url(r'^password_change/$',auth_views.password_change),
|
||||||
|
|||||||
Reference in New Issue
Block a user