logging of validaitons
This commit is contained in:
@@ -349,6 +349,8 @@ def handle_check_race_course(self,
|
||||
recordid,useremail,userfirstname,
|
||||
**kwargs):
|
||||
|
||||
logfile = 'courselog_{workoutid}_{courseid}.log'.format(workoutid=workoutid,courseid=courseid)
|
||||
|
||||
if 'debug' in kwargs:
|
||||
debug = kwargs['debug']
|
||||
else:
|
||||
@@ -420,10 +422,11 @@ def handle_check_race_course(self,
|
||||
engine = create_engine(database_url, echo=False)
|
||||
|
||||
# get polygons
|
||||
query = "SELECT id FROM rowers_geopolygon WHERE course_id = {courseid} ORDER BY order_in_course ASC".format(
|
||||
query = "SELECT id,name FROM rowers_geopolygon WHERE course_id = {courseid} ORDER BY order_in_course ASC".format(
|
||||
courseid=courseid
|
||||
)
|
||||
|
||||
|
||||
with engine.connect() as conn, conn.begin():
|
||||
result = conn.execute(query)
|
||||
polygons = result.fetchall()
|
||||
@@ -441,7 +444,16 @@ def handle_check_race_course(self,
|
||||
|
||||
# check how many times went through start polygon
|
||||
try:
|
||||
entrytimes,entrydistances = time_in_path(rowdata,paths[0],maxmin='max',getall=True)
|
||||
entrytimes,entrydistances = time_in_path(rowdata,paths[0],maxmin='max',getall=True,
|
||||
name=polygons[0].name,logfile=logfile)
|
||||
with open(logfile,'a') as f:
|
||||
t = time.localtime()
|
||||
timestamp = time.strftime('%b-%d-%Y_%H%M', t)
|
||||
f.write('\n')
|
||||
f.write(timestamp)
|
||||
f.write(' ')
|
||||
f.write('Found {n} entrytimes'.format(n=len(entrytimes)))
|
||||
|
||||
except InvalidTrajectoryError:
|
||||
entrytimes = []
|
||||
entrydistances = []
|
||||
@@ -457,7 +469,13 @@ def handle_check_race_course(self,
|
||||
endseconds = []
|
||||
|
||||
for startt in entrytimes:
|
||||
|
||||
with open(logfile,'a') as f:
|
||||
t = time.localtime()
|
||||
timestamp = time.strftime('%b-%d-%Y_%H%M', t)
|
||||
f.write('\n')
|
||||
f.write(timestamp)
|
||||
f.write(' ')
|
||||
f.write('Path starting at {t}'.format(t=startt))
|
||||
rowdata2 = rowdata[rowdata['time']>(startt-10.)]
|
||||
|
||||
(
|
||||
@@ -465,13 +483,13 @@ def handle_check_race_course(self,
|
||||
coursemeters,
|
||||
coursecompleted,
|
||||
|
||||
) = coursetime_paths(rowdata2,paths)
|
||||
) = coursetime_paths(rowdata2,paths,polygons=polygons,logfile=logfile)
|
||||
(
|
||||
coursetimefirst,
|
||||
coursemetersfirst,
|
||||
firstcompleted
|
||||
) = coursetime_first(
|
||||
rowdata2,paths)
|
||||
rowdata2,paths,polygons=polygons,logfile=logfile)
|
||||
|
||||
|
||||
|
||||
@@ -541,6 +559,8 @@ def handle_check_race_course(self,
|
||||
conn.close()
|
||||
engine.dispose()
|
||||
|
||||
os.remove(logfile)
|
||||
|
||||
return 1
|
||||
|
||||
else:
|
||||
@@ -574,9 +594,11 @@ def handle_check_race_course(self,
|
||||
|
||||
# send email
|
||||
handle_sendemail_coursefail(
|
||||
useremail,userfirstname,
|
||||
useremail,userfirstname,logfile
|
||||
)
|
||||
|
||||
os.remove(logfile)
|
||||
|
||||
return 2
|
||||
|
||||
return 0
|
||||
@@ -1168,7 +1190,7 @@ def handle_sendemail_raceregistration(
|
||||
return 1
|
||||
|
||||
def handle_sendemail_coursefail(
|
||||
useremail, username, **kwargs):
|
||||
useremail, username, logfile, **kwargs):
|
||||
|
||||
if 'debug' in kwargs:
|
||||
debug = kwargs['debug']
|
||||
@@ -1186,7 +1208,10 @@ def handle_sendemail_coursefail(
|
||||
res = send_template_email(from_email,[useremail],
|
||||
subject,
|
||||
'trajectoryfailemail.html',
|
||||
d,**kwargs)
|
||||
d,
|
||||
cc=['info@rowsandall.com'],
|
||||
attach_file=logfile,
|
||||
**kwargs)
|
||||
|
||||
return 1
|
||||
|
||||
|
||||
Reference in New Issue
Block a user