From 5181f6c6ab48e6d72f866feca67b596bb4187e25 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Wed, 3 Apr 2019 16:27:51 +0200 Subject: [PATCH 1/3] fix #454 --- rowers/forms.py | 2 +- rowers/interactiveplots.py | 82 +++++++++++++++++--------------------- rowers/mailprocessing.py | 3 +- 3 files changed, 39 insertions(+), 48 deletions(-) diff --git a/rowers/forms.py b/rowers/forms.py index ae17b596..ff61a245 100644 --- a/rowers/forms.py +++ b/rowers/forms.py @@ -1193,7 +1193,7 @@ class ForceCurveOptionsForm(forms.Form): ('scatter','Peak Force Scatter Plot'), ('none','Only aggregrate data') ) - plottype = forms.ChoiceField(choices=plotchoices,initial='scatter', + plottype = forms.ChoiceField(choices=plotchoices,initial='line', label='Individual Stroke Chart Type') diff --git a/rowers/interactiveplots.py b/rowers/interactiveplots.py index e725c7c4..e1207fb6 100644 --- a/rowers/interactiveplots.py +++ b/rowers/interactiveplots.py @@ -337,41 +337,8 @@ def interactive_activitychart(workouts,startdate,enddate,stack='type'): p.toolbar_location = None p.sizing_mode = 'scale_width' -# p = hv.Bars(df,values='duration', -# label = CatAttr(columns=['date'], sort=False), -# xlabel='Date', -# ylabel='Time', -# title='Activity {d1} to {d2}'.format( -# d1 = startdate.strftime("%Y-%m-%d"), -# d2 = enddate.strftime("%Y-%m-%d"), -# ), -# stack=stack, -# plot_width=350, -# plot_height=250, -# toolbar_location = None, -# ) - - - - - - # for legend in p.legend: - # new_items = [] - # for legend_item in legend.items: - # it = legend_item.label['value'] - # tot = df[df[stack]==it].duration.sum() - # if tot != 0: - # new_items.append(legend_item) - # legend.items = new_items - # p.legend.location = "top_left" - # p.legend.background_fill_alpha = 0.7 - #p.sizing_mode = 'scale_width' - #p.sizing_mode = 'stretch_both' - - #p.yaxis.axis_label = 'Minutes' - script,div = components(p) return script,div @@ -786,55 +753,69 @@ def interactive_forcecurve(theworkouts,workstrokesonly=True,plottype='scatter'): plot.add_layout(avf) - peakflabel = Label(x=355,y=430,x_units='screen',y_units='screen', + peakflabel = Label(x=410,y=460,x_units='screen',y_units='screen', text="Fpeak: {peakforceav:6.2f}".format(peakforceav=peakforceav), background_fill_alpha=.7, background_fill_color='white', text_color='blue', ) - avflabel = Label(x=365,y=400,x_units='screen',y_units='screen', + avflabel = Label(x=420,y=430,x_units='screen',y_units='screen', text="Favg: {averageforceav:6.2f}".format(averageforceav=averageforceav), background_fill_alpha=.7, background_fill_color='white', text_color='blue', ) - catchlabel = Label(x=360,y=370,x_units='screen',y_units='screen', + catchlabel = Label(x=415,y=400,x_units='screen',y_units='screen', text="Catch: {catchav:6.2f}".format(catchav=catchav), background_fill_alpha=0.7, background_fill_color='white', text_color='red', ) - peakforceanglelabel = Label(x=320,y=340,x_units='screen',y_units='screen', + peakforceanglelabel = Label(x=375,y=370,x_units='screen',y_units='screen', text="Peak angle: {peakforceangleav:6.2f}".format(peakforceangleav=peakforceangleav), background_fill_alpha=0.7, background_fill_color='white', text_color='red', ) - finishlabel = Label(x=355,y=310,x_units='screen',y_units='screen', + finishlabel = Label(x=410,y=340,x_units='screen',y_units='screen', text="Finish: {finishav:6.2f}".format(finishav=finishav), background_fill_alpha=0.7, background_fill_color='white', text_color='red', ) - sliplabel = Label(x=370,y=280,x_units='screen',y_units='screen', + sliplabel = Label(x=425,y=310,x_units='screen',y_units='screen', text="Slip: {slipav:6.2f}".format(slipav=slipav-catchav), background_fill_alpha=0.7, background_fill_color='white', text_color='red', ) - washlabel = Label(x=360,y=250,x_units='screen',y_units='screen', + washlabel = Label(x=415,y=280,x_units='screen',y_units='screen', text="Wash: {washav:6.2f}".format(washav=finishav-washav), background_fill_alpha=0.7, background_fill_color='white', text_color='red', ) + lengthlabel = Label(x=405,y=250, x_units='screen',y_units='screen', + text="Length: {length:6.2f}".format(length=finishav-catchav), + background_fill_alpha=0.7, + background_fill_color='white', + text_color='green' + ) + + efflengthlabel = Label(x=340,y=220, x_units='screen',y_units='screen', + text="Effective Length: {length:6.2f}".format(length=washav-slipav), + background_fill_alpha=0.7, + background_fill_color='white', + text_color='green' + ) + annolabel = Label(x=50,y=450,x_units='screen',y_units='screen', text='', background_fill_alpha=0.7, @@ -859,6 +840,8 @@ def interactive_forcecurve(theworkouts,workstrokesonly=True,plottype='scatter'): plot.add_layout(finishlabel) plot.add_layout(annolabel) plot.add_layout(sliderlabel) + plot.add_layout(lengthlabel) + plot.add_layout(efflengthlabel) plot.xaxis.axis_label = "Angle" plot.yaxis.axis_label = "Force (N)" @@ -886,6 +869,8 @@ def interactive_forcecurve(theworkouts,workstrokesonly=True,plottype='scatter'): peakforceanglelabel=peakforceanglelabel, annolabel=annolabel, sliderlabel=sliderlabel, + lengthlabel=lengthlabel, + efflengthlabel=efflengthlabel, plottype=plottype, sourcemultiline=sourcemultiline, sourcemultiline2=sourcemultiline2 @@ -988,6 +973,9 @@ def interactive_forcecurve(theworkouts,workstrokesonly=True,plottype='scatter'): dataslipwash['xslip'] = [catchav+slipav,finishav-washav] dataslipwash['yslip'] = [thresholdforce,thresholdforce] + var length = finishav-catchav + var efflength = length-slipav-washav + avf.location = averageforceav avflabel.text = 'Favg: '+averageforceav.toFixed(2) catchlabel.text = 'Catch: '+catchav.toFixed(2) @@ -997,6 +985,8 @@ def interactive_forcecurve(theworkouts,workstrokesonly=True,plottype='scatter'): peakflabel.text = 'Fpeak: '+peakforceav.toFixed(2) peakforceanglelabel.text = 'Peak angle: '+peakforceangleav.toFixed(2) annolabel.text = annotation + lengthlabel.text = 'Length: '+length.toFixed(2) + efflengthlabel.text = 'Effective Length: '+efflength.toFixed(2) console.log(count); console.log(multilines['x'].length); @@ -1033,12 +1023,12 @@ def interactive_forcecurve(theworkouts,workstrokesonly=True,plottype='scatter'): distmax = 100+100*int(rowdata['distance'].max()/100.) - slider_dist_min = Slider(start=0,end=distmax,value=0,step=1, + slider_dist_min = Slider(start=0,end=distmax,value=0,step=50, title="Min Distance",callback=callback) callback.args["mindist"] = slider_dist_min slider_dist_max = Slider(start=0,end=distmax,value=distmax, - step=1, + step=50, title="Max Distance",callback=callback) callback.args["maxdist"] = slider_dist_max @@ -3323,12 +3313,12 @@ def interactive_cum_flex_chart2(theworkouts,promember=0, except KeyError: distmax = 1000. - slider_dist_min = Slider(start=0,end=distmax,value=0,step=1, + slider_dist_min = Slider(start=0,end=distmax,value=0,step=50, title="Min Distance",callback=callback) callback.args["mindist"] = slider_dist_min slider_dist_max = Slider(start=0,end=distmax,value=distmax, - step=1, + step=50, title="Max Distance",callback=callback) callback.args["maxdist"] = slider_dist_max @@ -3925,12 +3915,12 @@ def interactive_flex_chart2(id=0,promember=0, except (KeyError,ValueError): distmax = 100 - slider_dist_min = Slider(start=0,end=distmax,value=0,step=1, + slider_dist_min = Slider(start=0,end=distmax,value=0,step=50, title="Min Distance",callback=callback) callback.args["mindist"] = slider_dist_min slider_dist_max = Slider(start=0,end=distmax,value=distmax, - step=1, + step=50, title="Max Distance",callback=callback) callback.args["maxdist"] = slider_dist_max diff --git a/rowers/mailprocessing.py b/rowers/mailprocessing.py index 32e7f3b8..a7cc453a 100644 --- a/rowers/mailprocessing.py +++ b/rowers/mailprocessing.py @@ -106,7 +106,8 @@ def make_new_workout_from_email(rower, datafile, name, cntr=0,testing=False): if testing: print('Fileformat = ',fileformat) - + + if fileformat == 'unknown': # extension = datafilename[-4:].lower() # fcopy = "media/"+datafilename[:-4]+"_copy"+extension From c8f7d5541c33d0b06de14825a89fd0cd988832dd Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Wed, 3 Apr 2019 18:21:51 +0200 Subject: [PATCH 2/3] fix #455 --- rowers/templates/analysis.html | 70 ++++++++++++++-------------- rowers/templates/menu_analytics.html | 31 ++++++------ 2 files changed, 53 insertions(+), 48 deletions(-) diff --git a/rowers/templates/analysis.html b/rowers/templates/analysis.html index ee0d3664..d598c144 100644 --- a/rowers/templates/analysis.html +++ b/rowers/templates/analysis.html @@ -11,18 +11,6 @@
    -
  • -

    Ranking Pieces

    - -
    - Ranking Piece -
    -
    -

    - Analyze your Concept2 ranking pieces over a date range and predict your pace on other pieces. -

    -
  • Compare Workouts

    {% if team %} @@ -85,29 +73,6 @@ BETA: Box Chart Statistics of stroke metrics over a date range

  • -
  • -

    OTW Critical Power

    - -
    - OTW Critical Power -
    -
    -

    - Analyse power vs piece duration to make predictions. For On-The-Water rowing. -

    -
  • -
  • -

    OTE Critical Power

    - -
    - OTE Critical Power -
    -
    - -

    - Analyse power vs piece duration to make predictions, for erg pieces. -

    -
  • Trend Flex

    @@ -131,6 +96,41 @@ Monitoring power duration evidence from all your workouts. Feel free to explore.

  • +
  • +

    Ranking Pieces

    +
    +
    + Ranking Piece +
    +
    +

    + Analyze your Concept2 ranking pieces over a date range and predict your pace on other pieces. +

    +
  • +
  • +

    OTW Critical Power

    + +
    + OTW Critical Power +
    +
    +

    + Analyse power vs piece duration to make predictions. For On-The-Water rowing. +

    +
  • +
  • +

    OTE Critical Power

    + +
    + OTE Critical Power +
    +
    + +

    + Analyse power vs piece duration to make predictions, for erg pieces. +

    +
diff --git a/rowers/templates/menu_analytics.html b/rowers/templates/menu_analytics.html index 86bbd079..24b99117 100644 --- a/rowers/templates/menu_analytics.html +++ b/rowers/templates/menu_analytics.html @@ -5,20 +5,30 @@
  • +  Fitness +
      +
    • + {% if team %} + +  Compare + + {% else %} + +  Compare + + {% endif %} +
    • +
    • + +  Power Progress + +
    •  Ranking Pieces
    • -
    • - {% if team %} -  Compare - {% else %} -  Compare - {% endif %} -
    •  CP Chart OTE @@ -29,11 +39,6 @@  CP Chart OTW
    • -
    • - -  Power Progress - -
  • From 9fb2523b9af4cb88d61e05ad6d074a09672821f1 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Wed, 3 Apr 2019 21:17:58 +0200 Subject: [PATCH 3/3] fix --- rowers/management/commands/processemail.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rowers/management/commands/processemail.py b/rowers/management/commands/processemail.py index 6918fe70..25382b96 100644 --- a/rowers/management/commands/processemail.py +++ b/rowers/management/commands/processemail.py @@ -234,6 +234,8 @@ class Command(BaseCommand): ] except IOError: rowers = [] + except Message.DoesNotExist: + attachment.delete() for rower in rowers: if extension == 'zip': try: