more pep
This commit is contained in:
@@ -20,10 +20,8 @@ def time_in_path(df, p, maxmin='max', getall=False, name='unknown', logfile=None
|
||||
if df.empty: # pragma: no cover
|
||||
return 0
|
||||
|
||||
latitude = df.latitude
|
||||
longitude = df.longitude
|
||||
|
||||
def f(x): return coordinate_in_path(x['latitude'], x['longitude'], p)
|
||||
def f(x):
|
||||
return coordinate_in_path(x['latitude'], x['longitude'], p)
|
||||
|
||||
df['inpolygon'] = df.apply(f, axis=1)
|
||||
|
||||
|
||||
@@ -99,12 +99,12 @@ class RowerPlanMiddleWare(object):
|
||||
# remove from Free Coach groups
|
||||
|
||||
# send email
|
||||
job = myqueue(queue,
|
||||
handle_sendemail_expired,
|
||||
r.user.email,
|
||||
r.user.first_name,
|
||||
r.user.last_name,
|
||||
str(r.planexpires))
|
||||
_ = myqueue(queue,
|
||||
handle_sendemail_expired,
|
||||
r.user.email,
|
||||
r.user.first_name,
|
||||
r.user.last_name,
|
||||
str(r.planexpires))
|
||||
|
||||
response = self.get_response(request)
|
||||
|
||||
|
||||
@@ -38,8 +38,8 @@ class OpaqueEncoder:
|
||||
def transcode(self, i):
|
||||
"""Reversibly transcode a 32-bit integer to a scrambled form, returning a new 32-bit integer."""
|
||||
r = i & 0xffff
|
||||
l = i >> 16 & 0xffff ^ self.transform(r)
|
||||
return ((r ^ self.transform(l)) << 16) + l
|
||||
lla = i >> 16 & 0xffff ^ self.transform(r)
|
||||
return ((r ^ self.transform(lla)) << 16) + lla
|
||||
|
||||
def encode_hex(self, i):
|
||||
"""Transcode an integer and return it as an 8-character hex string."""
|
||||
|
||||
@@ -6,7 +6,6 @@ from rowers.models import (
|
||||
get_course_timezone, IndoorVirtualRaceResult, VirtualRace, createmacrofillers,
|
||||
createmesofillers, createmicrofillers, CourseStandard,
|
||||
)
|
||||
from rowers.utils import totaltime_sec_to_string
|
||||
from rowers.tasks import (
|
||||
handle_sendemail_raceregistration, handle_sendemail_racesubmission
|
||||
)
|
||||
@@ -372,8 +371,6 @@ def get_todays_micro(plan, thedate=timezone.now()):
|
||||
if thismicro:
|
||||
thismicro = thismicro[0]
|
||||
else: # pragma: no cover
|
||||
mms = TrainingMicroCycle.objects.all()
|
||||
|
||||
return None
|
||||
|
||||
return thismicro
|
||||
@@ -421,17 +418,14 @@ def add_workouts_plannedsession(ws, ps, r):
|
||||
coursecompleted=False,
|
||||
)
|
||||
record.save()
|
||||
job = myqueue(queue, handle_check_race_course, w.csvfilename,
|
||||
w.id, ps.course.id, record.id,
|
||||
w.user.user.email, w.user.user.first_name,
|
||||
mode='coursetest')
|
||||
_ = myqueue(queue, handle_check_race_course, w.csvfilename,
|
||||
w.id, ps.course.id, record.id,
|
||||
w.user.user.email, w.user.user.first_name,
|
||||
mode='coursetest')
|
||||
if ps.sessiontype == 'fastest_distance': # pragma: no cover
|
||||
records = CourseTestResult.objects.filter(
|
||||
userid=w.user.id, plannedsession=ps)
|
||||
for record in records:
|
||||
#w1 = Workout.objects.get(id=record.workoutid)
|
||||
#w1.plannedsession = None
|
||||
# w1.save()
|
||||
record.delete()
|
||||
|
||||
df = dataprep.getsmallrowdata_db(
|
||||
@@ -463,9 +457,6 @@ def add_workouts_plannedsession(ws, ps, r):
|
||||
records = CourseTestResult.objects.filter(
|
||||
userid=w.user.id, plannedsession=ps)
|
||||
for record in records:
|
||||
#w1 = Workout.objects.get(id=record.workoutid)
|
||||
#w1.plannedsession = None
|
||||
# w1.save()
|
||||
record.delete()
|
||||
|
||||
df = dataprep.getsmallrowdata_db(
|
||||
@@ -638,7 +629,7 @@ def is_session_complete_ws(ws, ps):
|
||||
value *= 1000.
|
||||
|
||||
cratiomin = 1
|
||||
cratiomax = 1
|
||||
# cratiomax = 1
|
||||
|
||||
cratios = {
|
||||
'better than nothing': 0,
|
||||
@@ -651,12 +642,12 @@ def is_session_complete_ws(ws, ps):
|
||||
if ps.criterium == 'none':
|
||||
if ps.sessiontype == 'session':
|
||||
cratiomin = 0.8
|
||||
cratiomax = 1.2
|
||||
# cratiomax = 1.2
|
||||
else:
|
||||
cratios['on target'] = 0.9167
|
||||
cratios['over target'] = 1.0833
|
||||
cratiomin = 0.9167
|
||||
cratiomax = 1.0833
|
||||
# cratiomax = 1.0833
|
||||
|
||||
score = 0
|
||||
completiondate = None
|
||||
@@ -790,10 +781,10 @@ def is_session_complete_ws(ws, ps):
|
||||
coursecompleted=False,
|
||||
)
|
||||
record.save()
|
||||
job = myqueue(queue, handle_check_race_course, ws[0].csvfilename,
|
||||
ws[0].id, ps.course.id, record.id,
|
||||
ws[0].user.user.email, ws[0].user.user.first_name,
|
||||
mode='coursetest')
|
||||
_ = myqueue(queue, handle_check_race_course, ws[0].csvfilename,
|
||||
ws[0].id, ps.course.id, record.id,
|
||||
ws[0].user.user.email, ws[0].user.user.first_name,
|
||||
mode='coursetest')
|
||||
|
||||
return (0, 'not done', None)
|
||||
|
||||
@@ -804,8 +795,6 @@ def is_session_complete_ws(ws, ps):
|
||||
|
||||
|
||||
def is_session_complete(r, ps):
|
||||
verdict = 'not done'
|
||||
|
||||
if r not in ps.rower.all(): # pragma: no cover
|
||||
return 0, 'not assigned', None
|
||||
|
||||
@@ -1290,7 +1279,7 @@ def race_can_submit(r, race):
|
||||
|
||||
if timezone.now() > startdatetime and timezone.now() < evaluation_closure:
|
||||
is_complete, has_registered = race_rower_status(r, race)
|
||||
if is_complete == False:
|
||||
if is_complete is False:
|
||||
return True
|
||||
else:
|
||||
return True
|
||||
@@ -1311,7 +1300,7 @@ def race_can_editentry(r, race):
|
||||
|
||||
if timezone.now() < evaluation_closure:
|
||||
is_complete, has_registered = race_rower_status(r, race)
|
||||
if is_complete == False:
|
||||
if is_complete is False:
|
||||
return True
|
||||
else: # pragma: no cover
|
||||
return False
|
||||
@@ -1594,7 +1583,6 @@ def add_workout_fastestrace(ws, race, r, recordid=0, doregister=False):
|
||||
errors.append('For tests, you can only attach one workout')
|
||||
return result, comments, errors, 0
|
||||
|
||||
username = r.user.first_name+' '+r.user.last_name
|
||||
if r.birthdate:
|
||||
age = calculate_age(r.birthdate)
|
||||
else: # pragma: no cover
|
||||
@@ -1634,7 +1622,6 @@ def add_workout_fastestrace(ws, race, r, recordid=0, doregister=False):
|
||||
records = IndoorVirtualRaceResult.objects.filter(
|
||||
userid=r.id,
|
||||
race=race,
|
||||
#workoutid = ws[0].id
|
||||
)
|
||||
|
||||
if ws[0].workouttype != record.boatclass: # pragma: no cover
|
||||
@@ -1767,7 +1754,6 @@ def add_workout_indoorrace(ws, race, r, recordid=0, doregister=False):
|
||||
errors.append('For tests, you can only attach one workout')
|
||||
return result, comments, errors, 0
|
||||
|
||||
username = r.user.first_name+' '+r.user.last_name
|
||||
if r.birthdate:
|
||||
age = calculate_age(r.birthdate)
|
||||
else: # pragma: no cover
|
||||
@@ -1915,7 +1901,6 @@ def add_workout_race(ws, race, r, splitsecond=0, recordid=0, doregister=False):
|
||||
errors.append('For tests, you can only attach one workout')
|
||||
return result, comments, errors, 0
|
||||
|
||||
username = r.user.first_name+' '+r.user.last_name
|
||||
if r.birthdate:
|
||||
age = calculate_age(r.birthdate)
|
||||
else: # pragma: no cover
|
||||
@@ -1971,8 +1956,6 @@ def add_workout_race(ws, race, r, splitsecond=0, recordid=0, doregister=False):
|
||||
if ws[0].workouttype != record.boatclass: # pragma: no cover
|
||||
ws[0].workouttype = record.boatclass
|
||||
ws[0].save()
|
||||
#errors.append('Your workout boat class is different than on your race registration')
|
||||
# return 0,comments,errors,0
|
||||
|
||||
if ws[0].boattype != record.boattype: # pragma: no cover
|
||||
errors.append(
|
||||
|
||||
@@ -164,7 +164,7 @@ def createsporttracksworkoutdata(w):
|
||||
return 0
|
||||
|
||||
# adding diff, trying to see if this is valid
|
||||
#t = row.df.loc[:,'TimeStamp (sec)'].values-10*row.df.ix[0,'TimeStamp (sec)']
|
||||
# t = row.df.loc[:,'TimeStamp (sec)'].values-10*row.df.ix[0,'TimeStamp (sec)']
|
||||
t = row.df.loc[:, 'TimeStamp (sec)'].values - \
|
||||
row.df.loc[:, 'TimeStamp (sec)'].iloc[0]
|
||||
try:
|
||||
@@ -293,7 +293,6 @@ def workout_sporttracks_upload(user, w, asynchron=False): # pragma: no cover
|
||||
message = "Uploading to SportTracks"
|
||||
stid = 0
|
||||
# ready to upload. Hurray
|
||||
r = w.user
|
||||
|
||||
thetoken = sporttracks_open(user)
|
||||
|
||||
@@ -311,8 +310,8 @@ def workout_sporttracks_upload(user, w, asynchron=False): # pragma: no cover
|
||||
|
||||
url = "https://api.sporttracks.mobi/api/v2/fitnessActivities.json"
|
||||
if asynchron:
|
||||
job = myqueue(queue, handle_sporttracks_sync,
|
||||
w.id, url, headers, json.dumps(data, default=default))
|
||||
_ = myqueue(queue, handle_sporttracks_sync,
|
||||
w.id, url, headers, json.dumps(data, default=default))
|
||||
return "Asynchronous sync", 0
|
||||
|
||||
response = requests.post(url, headers=headers,
|
||||
@@ -398,9 +397,9 @@ def add_workout_from_data(user, importid, data, strokedata, source='sporttracks'
|
||||
return (0, "No distance or heart rate data in the workout")
|
||||
|
||||
try:
|
||||
l = data['location']
|
||||
locs = data['location']
|
||||
|
||||
res = splitstdata(l)
|
||||
res = splitstdata(locs)
|
||||
times_location = res[0]
|
||||
latlong = res[1]
|
||||
latcoord = []
|
||||
@@ -492,8 +491,6 @@ def add_workout_from_data(user, importid, data, strokedata, source='sporttracks'
|
||||
|
||||
df.sort_values(by='TimeStamp (sec)', ascending=True)
|
||||
|
||||
timestr = strftime("%Y%m%d-%H%M%S")
|
||||
|
||||
# csvfilename ='media/Import_'+str(importid)+'.csv'
|
||||
csvfilename = 'media/{code}_{importid}.csv'.format(
|
||||
importid=importid,
|
||||
|
||||
@@ -70,7 +70,7 @@ def get_metar_data(airportcode, unixtime):
|
||||
lengte = len(doc.xpath('data/METAR/station_id'))
|
||||
idnr = int(lengte/2)
|
||||
try:
|
||||
id = doc.xpath('data/METAR/station_id')[idnr].text
|
||||
_ = doc.xpath('data/METAR/station_id')[idnr].text
|
||||
temp_c = doc.xpath('data/METAR/temp_c')[idnr].text
|
||||
wind_dir = doc.xpath('data/METAR/wind_dir_degrees')[idnr].text
|
||||
wind_speed = doc.xpath('data/METAR/wind_speed_kt')[idnr].text
|
||||
@@ -138,7 +138,7 @@ def get_wind_data(lat, long, unixtime):
|
||||
windbearing = 0
|
||||
summary = 'unknown'
|
||||
airports = ['unknown']
|
||||
temparature = 'unknown'
|
||||
temperature = 'unknown'
|
||||
temperaturec = 'unknown'
|
||||
message = 'Not able to get weather data'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user