using async job to calculate predicted age records and store in db
This commit is contained in:
@@ -3,6 +3,7 @@ import numpy as np
|
||||
from models import C2WorldClassAgePerformance
|
||||
import pandas as pd
|
||||
from scipy import optimize
|
||||
from django.utils import timezone
|
||||
|
||||
rowingmetrics = (
|
||||
('time',{
|
||||
@@ -321,28 +322,36 @@ def calc_trimp(df,sex,hrmax,hrmin):
|
||||
return trimp
|
||||
|
||||
def getagegrouprecord(age,sex='male',weightcategory='hwt',
|
||||
distance=2000,duration=None):
|
||||
if not duration:
|
||||
df = pd.DataFrame(
|
||||
list(
|
||||
C2WorldClassAgePerformance.objects.filter(
|
||||
distance=distance,
|
||||
sex=sex,
|
||||
weightcategory=weightcategory
|
||||
).values()
|
||||
)
|
||||
)
|
||||
distance=2000,duration=None,indf=pd.DataFrame()):
|
||||
|
||||
if not indf.empty:
|
||||
if not duration:
|
||||
df = indf[indf['distance'] == distance]
|
||||
else:
|
||||
duration = 60*int(duration)
|
||||
df = indf[indf['duration'] == duration]
|
||||
else:
|
||||
duration=60*int(duration)
|
||||
df = pd.DataFrame(
|
||||
list(
|
||||
C2WorldClassAgePerformance.objects.filter(
|
||||
duration=duration,
|
||||
sex=sex,
|
||||
weightcategory=weightcategory
|
||||
).values()
|
||||
if not duration:
|
||||
df = pd.DataFrame(
|
||||
list(
|
||||
C2WorldClassAgePerformance.objects.filter(
|
||||
distance=distance,
|
||||
sex=sex,
|
||||
weightcategory=weightcategory
|
||||
).values()
|
||||
)
|
||||
)
|
||||
else:
|
||||
duration=60*int(duration)
|
||||
df = pd.DataFrame(
|
||||
list(
|
||||
C2WorldClassAgePerformance.objects.filter(
|
||||
duration=duration,
|
||||
sex=sex,
|
||||
weightcategory=weightcategory
|
||||
).values()
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
if not df.empty:
|
||||
ages = df['age']
|
||||
|
||||
Reference in New Issue
Block a user