From 44af254aa254cfc6b625e8b33cfc8a3e1260c202 Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Wed, 14 Sep 2022 16:53:15 +0200 Subject: [PATCH] fix trendflex --- rowers/templates/user_analysis_select.html | 4 +- rowers/tests/test_analysis.py | 63 ++++++++++++++++++++++ rowers/views/analysisviews.py | 2 +- 3 files changed, 67 insertions(+), 2 deletions(-) diff --git a/rowers/templates/user_analysis_select.html b/rowers/templates/user_analysis_select.html index f952b9b2..fef97632 100644 --- a/rowers/templates/user_analysis_select.html +++ b/rowers/templates/user_analysis_select.html @@ -132,6 +132,8 @@ palette.show(); binsize.show(); errorbars.show(); + workmin.show(); + workmax.show(); }; if (functionfield.val() == 'flexall') { @@ -392,7 +394,7 @@ and weight category ({{ weightcategory }}). The Gold Medal Standard power is derived from the - World Record for your category. + World Record for your category. The percentile lines are estimates of where the percentiles of the Concept2 rankings historically are for those of exactly your age, gender and weight class. diff --git a/rowers/tests/test_analysis.py b/rowers/tests/test_analysis.py index 65c4e4f6..75990e0b 100644 --- a/rowers/tests/test_analysis.py +++ b/rowers/tests/test_analysis.py @@ -830,6 +830,69 @@ class WorkoutStatsTestNew(TestCase): script, div = statsdata(workouts,options) script, div = comparisondata(workouts,options) + @patch('rowers.dataprep.create_engine') + @patch('rowers.dataprep.getsmallrowdata_db', side_effect=mocked_getsmallrowdata_db) + @patch('rowers.dataprep.read_cols_df_sql', side_effect=mocked_read_cols_df_sql) + def test_analysis_data2(self, + mocked_sqlalchemy, + mocked_getsmallrowdata_db, + mocked_read_cols_df_sql, + ): + + startdate = (self.user_workouts[0].startdatetime-datetime.timedelta(days=3)).date() + enddate = (self.user_workouts[0].startdatetime+datetime.timedelta(days=3)).date() + + # make sure the dates are not naive + try: + startdate = pytz.utc.localize(startdate) + except (ValueError, AttributeError): + pass + try: + enddate = pytz.utc.localize(enddate) + except (ValueError, AttributeError): + pass + + options = { + 'function':'flexall', + 'xparam':'spm', + 'plotfield':'spm', + 'yparam':'power', + 'groupby':'spm', + 'binsize':1, + 'ploterrorbars':True, + 'palette':'monochrome_blue', + 'xaxis':'time', + 'yaxis1':'power', + 'yaxis2':'hr', + 'startdate':startdate, + 'enddate':enddate, + 'plottype':'scatter', + 'spmmin':15, + 'spmmax':55, + 'workmin':0, + 'workmax':1500, + 'cpfit':'data', + 'piece': 4, + 'cpoverlay':True, + 'cpfit':'data', + 'includereststrokes':False, + 'modality':'all', + 'waterboattype':['1x','2x','4x'], + 'ids':[1,2,3], + 'userid':self.u.id, + } + + workouts = self.user_workouts + + script, div = boxplotdata(workouts,options) + script, div = trendflexdata(workouts,options) + script, div = histodata(workouts,options) + script, div = cpdata(workouts,options) + script, div = flexalldata(workouts,options) + script, div = statsdata(workouts,options) + script, div = comparisondata(workouts,options) + + @patch('rowers.dataprep.create_engine') @patch('rowers.dataprep.getsmallrowdata_db', side_effect=mocked_getsmallrowdata_db) @patch('rowers.dataprep.read_cols_df_sql', side_effect=mocked_read_cols_df_sql) diff --git a/rowers/views/analysisviews.py b/rowers/views/analysisviews.py index af28f6cd..b5a3cbb7 100644 --- a/rowers/views/analysisviews.py +++ b/rowers/views/analysisviews.py @@ -317,7 +317,7 @@ def trendflexdata(workouts, options, userid=0): if xparam == groupby: # pragma: no cover datadf['groupby'] = datadf[xparam] - groupby = 'groupby' + #groupby = 'groupby' datadf = dataprep.clean_df_stats(datadf, workstrokesonly=workstrokesonly)