Private
Public Access
1
0

Merge branch 'feature/usersmooth' into develop

This commit is contained in:
Sander Roosendaal
2020-11-04 21:51:20 +01:00
5 changed files with 63 additions and 3 deletions

View File

@@ -13,7 +13,7 @@ from rowingdata import main as rmain
from rowingdata import cumcpdata,histodata
from rowingdata import rowingdata as rrdata
from math import pi
from math import pi,log2
from django.utils import timezone
from rowingdata import make_cumvalues
@@ -79,6 +79,7 @@ from scipy.interpolate import griddata
import rowers.stravastuff as stravastuff
from rowers.metrics import rowingmetrics,metricsdicts
from rowers.dataprep import rdata
import rowers.dataprep as dataprep
@@ -4442,6 +4443,17 @@ def interactive_flex_chart2(id,r,promember=0,
rowdata = dataprep.getsmallrowdata_db(columns,ids=[id],doclean=True,
workstrokesonly=workstrokesonly)
if r.usersmooth > 1:
for column in columns:
try:
if metricsdicts[column]['maysmooth']:
nrsteps = int(log2(r.usersmooth))
for i in range(nrsteps):
rowdata[column] = stravastuff.ewmovingaverage(rowdata[column],5)
except KeyError:
pass
if len(rowdata)<2:
rowdata = dataprep.getsmallrowdata_db(columns,ids=[id],doclean=True,

View File

@@ -11,7 +11,7 @@ import pandas as pd
from scipy import optimize
from django.utils import timezone
from math import log10
from math import log10,log2
from rowers.mytypes import otwtypes,otetypes
nometrics = [
@@ -58,6 +58,7 @@ rowingmetrics = (
'mode':'both',
'type': 'basic',
'group':'basic',
'maysmooth': False,
'sigfigs': -1}),
('hr',{
@@ -68,6 +69,7 @@ rowingmetrics = (
'ax_max': 200,
'mode':'both',
'type': 'basic',
'maysmooth': False,
'group':'athlete',
'sigfigs':0,}),
@@ -80,6 +82,7 @@ rowingmetrics = (
'mode':'both',
'type': 'basic',
'sigfigs': 1,
'maysmooth': True,
'group': 'basic'}),
('velo',{
@@ -91,6 +94,7 @@ rowingmetrics = (
'default': 0,
'mode':'both',
'sigfigs': 1,
'maysmooth': True,
'type':'pro',
'group': 'basic'}),
@@ -113,6 +117,7 @@ rowingmetrics = (
'mode':'both',
'sigfigs': 1,
'type': 'basic',
'maysmooth': True,
'group':'basic'}),
('driveenergy',{
@@ -124,6 +129,7 @@ rowingmetrics = (
'mode':'both',
'sigfigs': 0,
'type': 'pro',
'maysmooth': True,
'group':'forcepower'}),
('power',{
@@ -135,6 +141,7 @@ rowingmetrics = (
'mode':'both',
'sigfigs': 0,
'type': 'basic',
'maysmooth': True,
'group':'forcepower'}),
('averageforce',{
@@ -145,6 +152,7 @@ rowingmetrics = (
'ax_max': 1200,
'mode':'both',
'sigfigs': 0,
'maysmooth': True,
'type': 'pro',
'group':'forcepower'}),
@@ -156,6 +164,7 @@ rowingmetrics = (
'ax_max': 1500,
'sigfigs': 0,
'mode':'both',
'maysmooth': True,
'type': 'pro',
'group':'forcepower'}),
@@ -167,6 +176,7 @@ rowingmetrics = (
'ax_max': 2.5,
'mode':'rower',
'sigfigs': 2,
'maysmooth': False,
'type': 'pro',
'group':'stroke'}),
@@ -177,6 +187,7 @@ rowingmetrics = (
'ax_min': 0,
'ax_max': 1,
'sigfigs': 2,
'maysmooth': True,
'mode':'both',
'type': 'pro',
'group': 'forcepower'}),
@@ -189,6 +200,7 @@ rowingmetrics = (
'ax_max': 1e5,
'sigfigs': 0,
'mode':'both',
'maysmooth': False,
'type': 'basic',
'group':'basic'}),
@@ -200,6 +212,7 @@ rowingmetrics = (
'ax_max': 1e5,
'mode':'both',
'sigfigs': 0,
'maysmooth': False,
'type': 'basic',
'group':'basic'}),
@@ -211,6 +224,7 @@ rowingmetrics = (
'ax_max': 4,
'default': 0,
'sigfigs': 2,
'maysmooth': True,
'mode':'both',
'type': 'pro',
'group': 'stroke'}),
@@ -225,6 +239,7 @@ rowingmetrics = (
'default': 0,
'sigfigs': 0,
'mode':'water',
'maysmooth': True,
'type': 'pro',
'group': 'stroke'}),
@@ -236,6 +251,7 @@ rowingmetrics = (
'ax_max': 20,
'default': 0,
'sigfigs': 1,
'maysmooth': True,
'mode':'water',
'type': 'pro',
'group': 'stroke'}),
@@ -248,6 +264,7 @@ rowingmetrics = (
'ax_max': 55,
'default': 0,
'sigfigs': 0,
'maysmooth': True,
'mode':'water',
'type': 'pro',
'group': 'stroke'}),
@@ -260,6 +277,7 @@ rowingmetrics = (
'ax_max': 30,
'default': 0,
'sigfigs': 1,
'maysmooth': True,
'mode':'water',
'type': 'pro',
'group': 'stroke'}),
@@ -272,6 +290,7 @@ rowingmetrics = (
'ax_max': 50,
'default': 0,
'sigfigs': 0,
'maysmooth': True,
'mode':'water',
'type': 'pro',
'group':'stroke'}),
@@ -285,6 +304,7 @@ rowingmetrics = (
'ax_max': 140,
'default': 0,
'sigfigs': 0,
'maysmooth': True,
'mode':'water',
'type': 'pro',
'group':'stroke'}),
@@ -299,6 +319,7 @@ rowingmetrics = (
'default': 0,
'sigfigs': 0,
'mode':'water',
'maysmooth': True,
'type': 'pro',
'group':'stroke'}),
@@ -311,6 +332,7 @@ rowingmetrics = (
'default': 1.0,
'sigfigs': 0,
'mode':'erg',
'maysmooth': True,
'type': 'pro',
'group':'stroke'}),
@@ -323,6 +345,7 @@ rowingmetrics = (
'default': 0,
'sigfigs': 0,
'mode':'water',
'maysmooth': True,
'type': 'pro',
'group':'forcepower'}),
@@ -334,12 +357,19 @@ rowingmetrics = (
'ax_max': 15,
'default': 0,
'sigfigs': 1,
'maysmooth': True,
'mode':'both',
'type': 'basic',
'group':'basic'}),
)
metricsdicts = {}
for key,dict in rowingmetrics:
metricsdicts[key] = dict
metricsgroups = list(set([d['group'] for n,d in rowingmetrics]))
dtypes = {}

View File

@@ -84,6 +84,14 @@ favanalysischoices = (
('cp','Critical Power'),
)
smoothingchoices = (
(1,1),
(2,2),
(4,4),
(8,8),
(16,16),
)
def half_year_from_now():
return (datetime.datetime.now(tz=timezone.utc)+timezone.timedelta(days=182)).date()
@@ -991,6 +999,9 @@ class Rower(models.Model):
max_length=100,
verbose_name='Favorite Analysis')
usersmooth = models.IntegerField(default=1,choices=smoothingchoices,
verbose_name="Chart Smoothing")
staticchartonupload = models.CharField(default='None',choices=plotchoices,
max_length=100,
verbose_name='Generate a static chart automatically on upload')
@@ -3778,6 +3789,7 @@ class AccountRowerForm(ModelForm):
'getimportantemails',
'defaulttimezone','showfavoritechartnotes',
'fav_analysis',
'usersmooth',
'defaultlandingpage',
'offercoaching','autojoin','emailalternatives']
@@ -3817,7 +3829,7 @@ class AccountRowerForm(ModelForm):
class StaticChartRowerForm(ModelForm):
class Meta:
model = Rower
fields = ['staticgrids','slowpaceerg','fastpaceerg','slowpaceotw','fastpaceotw','staticchartonupload','fav_analysis']
fields = ['usersmooth','staticgrids','slowpaceerg','fastpaceerg','slowpaceotw','fastpaceotw','staticchartonupload','fav_analysis']
def __init__(self, *args, **kwargs):
super(StaticChartRowerForm, self).__init__(*args, **kwargs)

View File

@@ -114,6 +114,7 @@ class UserPreferencesTest(TestCase):
'defaulttimezone':'UTC',
'showfavoritechartnotes':False,
'fav_analysis':'compare',
'usersmooth':2,
'defaultlandingpage':'workout_edit_view',
'first_name': self.u.first_name,
'last_name': self.u.last_name,

View File

@@ -247,6 +247,7 @@ def rower_favoritecharts_view(request,userid=0):
r.fastpaceotw = staticchartform.cleaned_data.get('fastpaceotw')
r.staticchartonupload = staticchartform.cleaned_data.get('staticchartonupload')
r.fav_analysis = staticchartform.cleaned_data.get('fav_analysis')
r.usersmooth = staticchartform.cleaned_data.get('usersmooth')
r.save()
if request.method == 'POST' and 'form-TOTAL_FORMS' in request.POST:
@@ -405,6 +406,8 @@ def rower_edit_view(request,rowerid=0,userid=0,message=""):
getemailnotifications = cd['getemailnotifications']
getimportantemails = cd['getimportantemails']
defaulttimezone=cd['defaulttimezone']
fav_analysis = cd['fav_analysis']
usersmooth = cd['usersmooth']
u = r.user
if u.email != email and len(email):
resetbounce = True
@@ -432,6 +435,8 @@ def rower_edit_view(request,rowerid=0,userid=0,message=""):
r.birthdate = birthdate
r.autojoin = autojoin
r.emailalternatives = emailalternatives
r.fav_analysis = fav_analysis
r.usersmooth = usersmooth
if resetbounce and r.emailbounced: