Private
Public Access
1
0

bug fixes

This commit is contained in:
Sander Roosendaal
2018-11-19 11:29:10 +01:00
parent bd2c6a21b9
commit 886b05fe8a
2 changed files with 31 additions and 17 deletions

View File

@@ -1,6 +1,6 @@
from __future__ import unicode_literals 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.contrib.auth.models import User
from django.core.validators import validate_email from django.core.validators import validate_email
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
@@ -201,9 +201,11 @@ def update_records(url=c2url):
name = name, name = name,
) )
try: try:
record.save()
except:
print record print record
record.save()
except IntegrityError:
print(record,'*')
class CalcAgePerformance(models.Model): class CalcAgePerformance(models.Model):
@@ -281,7 +283,17 @@ class C2WorldClassAgePerformance(models.Model):
unique_together = ('age','sex','weightcategory','distance') unique_together = ('age','sex','weightcategory','distance')
def __unicode__(self): 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 # For future Team functionality
class Team(models.Model): class Team(models.Model):

View File

@@ -405,12 +405,13 @@ def handle_getagegrouprecords(self,
weightcategory=weightcategory,indf=df, weightcategory=weightcategory,indf=df,
) )
velo = (worldclasspower/2.8)**(1./3.) velo = (worldclasspower/2.8)**(1./3.)
try: if not np.isinf(worldclasspower) and not np.isnan(worldclasspower):
duration = distance/velo try:
wcdurations.append(duration) duration = distance/velo
wcpower.append(worldclasspower) wcdurations.append(duration)
except ZeroDivisionError: wcpower.append(worldclasspower)
pass except ZeroDivisionError:
pass
@@ -421,13 +422,14 @@ def handle_getagegrouprecords(self,
duration=duration, duration=duration,
weightcategory=weightcategory,indf=df weightcategory=weightcategory,indf=df
) )
try: if not np.isinf(worldclasspower) and not np.isnan(worldclasspower):
velo = (worldclasspower/2.8)**(1./3.) try:
distance = int(60*duration*velo) velo = (worldclasspower/2.8)**(1./3.)
wcdurations.append(60.*duration) distance = int(60*duration*velo)
wcpower.append(worldclasspower) wcdurations.append(60.*duration)
except ValueError: wcpower.append(worldclasspower)
pass except ValueError:
pass
update_agegroup_db(age,sex,weightcategory,wcdurations,wcpower, update_agegroup_db(age,sex,weightcategory,wcdurations,wcpower,
debug=debug) debug=debug)