does Alternative OTE ranking
added an OTE ranking piece calculator based on manually added ranking instead of automatically detected ranking
This commit is contained in:
@@ -473,21 +473,37 @@ def updatecpdata_sql(rower_id,delta,cp,table='cpdata',distance=[]):
|
||||
engine.dispose()
|
||||
|
||||
|
||||
def runcpupdate(rower):
|
||||
def runcpupdate(rower,type='water'):
|
||||
startdate = timezone.now()-datetime.timedelta(days=365)
|
||||
enddate = timezone.now()+datetime.timedelta(days=5)
|
||||
theworkouts = Workout.objects.filter(user=rower,rankingpiece=True,
|
||||
workouttype='water',
|
||||
startdatetime__gte=startdate,
|
||||
startdatetime__lte=enddate)
|
||||
if type == 'water':
|
||||
theworkouts = Workout.objects.filter(
|
||||
user=rower,rankingpiece=True,
|
||||
workouttype='water',
|
||||
startdatetime__gte=startdate,
|
||||
startdatetime__lte=enddate
|
||||
)
|
||||
table = 'cpdata'
|
||||
else:
|
||||
theworkouts = Workout.objects.filter(
|
||||
user=rower,rankingpiece=True,
|
||||
workouttype__in=[
|
||||
'rower',
|
||||
'dynamic',
|
||||
'slides'
|
||||
],
|
||||
startdatetime__gte=startdate,
|
||||
startdatetime__lte=enddate
|
||||
)
|
||||
table = 'cpergdata'
|
||||
|
||||
theids = [w.id for w in theworkouts]
|
||||
|
||||
|
||||
if settings.DEBUG:
|
||||
res = handle_updatecp.delay(rower.id,theids,debug=True)
|
||||
res = handle_updatecp.delay(rower.id,theids,debug=True,table=table)
|
||||
else:
|
||||
res = queue.enqueue(handle_updatecp,rower.id,theids)
|
||||
res = queue.enqueue(handle_updatecp,rower.id,theids,table=table)
|
||||
|
||||
def fetchcperg(rower,theworkouts):
|
||||
theids = [int(w.id) for w in theworkouts]
|
||||
@@ -502,24 +518,29 @@ def fetchcperg(rower,theworkouts):
|
||||
return cpdf
|
||||
|
||||
|
||||
def fetchcp(rower,theworkouts):
|
||||
def fetchcp(rower,theworkouts,table='cpdata'):
|
||||
# get all power data from database (plus workoutid)
|
||||
theids = [int(w.id) for w in theworkouts]
|
||||
columns = ['power','workoutid','time']
|
||||
df = getsmallrowdata_db(columns,ids=theids)
|
||||
if df.empty:
|
||||
avgpower2 = {}
|
||||
for id in theids:
|
||||
avgpower2[id] = 0
|
||||
return pd.Series([]),pd.Series([]),avgpower2
|
||||
|
||||
dfgrouped = df.groupby(['workoutid'])
|
||||
avgpower2 = dict(dfgrouped.mean()['power'].astype(int))
|
||||
|
||||
cpdf = getcpdata_sql(rower.id)
|
||||
cpdf = getcpdata_sql(rower.id,table=table)
|
||||
|
||||
if not cpdf.empty:
|
||||
return cpdf['delta'],cpdf['cp'],avgpower2
|
||||
else:
|
||||
if settings.DEBUG:
|
||||
res = handle_updatecp.delay(rower.id,theids,debug=True)
|
||||
res = handle_updatecp.delay(rower.id,theids,debug=True,table=table)
|
||||
else:
|
||||
res = queue.enqueue(handle_updatecp,rower.id,theids)
|
||||
res = queue.enqueue(handle_updatecp,rower.id,theids,table=table)
|
||||
return [],[],avgpower2
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user