bug fixes
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models
|
||||
from django.db import models,IntegrityError
|
||||
from django.contrib.auth.models import User
|
||||
from django.core.validators import validate_email
|
||||
from django.core.exceptions import ValidationError
|
||||
@@ -201,9 +201,11 @@ def update_records(url=c2url):
|
||||
name = name,
|
||||
)
|
||||
try:
|
||||
record.save()
|
||||
except:
|
||||
print record
|
||||
record.save()
|
||||
except IntegrityError:
|
||||
print(record,'*')
|
||||
|
||||
|
||||
|
||||
class CalcAgePerformance(models.Model):
|
||||
@@ -281,7 +283,17 @@ class C2WorldClassAgePerformance(models.Model):
|
||||
unique_together = ('age','sex','weightcategory','distance')
|
||||
|
||||
def __unicode__(self):
|
||||
return self.sex+' '+self.weightcategory+' '+self.name+':'+str(self.age)+' ('+str(self.season)+')'
|
||||
thestring = '{s} {w} {n} age {a} ({season}) {distance}m {duration} seconds'.format(
|
||||
s = self.sex,
|
||||
w = self.weightcategory,
|
||||
n = self.name,
|
||||
a = self.age,
|
||||
season = self.season,
|
||||
distance = self.distance,
|
||||
duration = self.duration,
|
||||
)
|
||||
|
||||
return thestring
|
||||
|
||||
# For future Team functionality
|
||||
class Team(models.Model):
|
||||
|
||||
@@ -405,12 +405,13 @@ def handle_getagegrouprecords(self,
|
||||
weightcategory=weightcategory,indf=df,
|
||||
)
|
||||
velo = (worldclasspower/2.8)**(1./3.)
|
||||
try:
|
||||
duration = distance/velo
|
||||
wcdurations.append(duration)
|
||||
wcpower.append(worldclasspower)
|
||||
except ZeroDivisionError:
|
||||
pass
|
||||
if not np.isinf(worldclasspower) and not np.isnan(worldclasspower):
|
||||
try:
|
||||
duration = distance/velo
|
||||
wcdurations.append(duration)
|
||||
wcpower.append(worldclasspower)
|
||||
except ZeroDivisionError:
|
||||
pass
|
||||
|
||||
|
||||
|
||||
@@ -421,13 +422,14 @@ def handle_getagegrouprecords(self,
|
||||
duration=duration,
|
||||
weightcategory=weightcategory,indf=df
|
||||
)
|
||||
try:
|
||||
velo = (worldclasspower/2.8)**(1./3.)
|
||||
distance = int(60*duration*velo)
|
||||
wcdurations.append(60.*duration)
|
||||
wcpower.append(worldclasspower)
|
||||
except ValueError:
|
||||
pass
|
||||
if not np.isinf(worldclasspower) and not np.isnan(worldclasspower):
|
||||
try:
|
||||
velo = (worldclasspower/2.8)**(1./3.)
|
||||
distance = int(60*duration*velo)
|
||||
wcdurations.append(60.*duration)
|
||||
wcpower.append(worldclasspower)
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
update_agegroup_db(age,sex,weightcategory,wcdurations,wcpower,
|
||||
debug=debug)
|
||||
|
||||
Reference in New Issue
Block a user