From e3876ec85d16d97b25cfe886ef9ab1d00866b3a6 Mon Sep 17 00:00:00 2001
From: Sander Roosendaal
Date: Sat, 14 Oct 2017 10:05:29 +0200
Subject: [PATCH 1/4] timestamp takes into account non UTC in weather
---
rowers/weather.py | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/rowers/weather.py b/rowers/weather.py
index 9acf5154..3e9bd4e0 100644
--- a/rowers/weather.py
+++ b/rowers/weather.py
@@ -5,6 +5,7 @@ import xml.etree.ElementTree as ET
import time
from datetime import datetime
from rowingdata import rowingdata,geo_distance
+import arrow
import pandas as pd
from rowers.models import Rower, Workout
@@ -36,8 +37,8 @@ def get_weather_data(long,lat,unixtime):
# Get Metar data
def get_metar_data(airportcode,unixtime):
- timestamp = datetime.utcfromtimestamp(unixtime).isoformat()+'Z'
-
+ timestamp = arrow.get(unixtime).isoformat()
+
url = "https://www.aviationweather.gov/adds/dataserver_current/httpparam?dataSource=metars&requestType=retrieve&format=xml&startTime="
url += str(unixtime-3600)
url += "&endTime="
@@ -122,8 +123,8 @@ def get_wind_data(lat,long,unixtime):
windspeed = windspeed*(0.1)**0.34
windspeed = 0.01*int(100*windspeed)
- timestamp = datetime.utcfromtimestamp(unixtime).isoformat()+'Z'
-
+ timestamp = arrow.get(unixtime).isoformat()
+
message = 'Summary for your location at '+timestamp+': '+summary
message += '. Temperature '+str(temperature)+'F/'+str(temperaturec)+'C'
From 38e6880e9c04ab4b2318ded6ff2deb70ab4cc6ab Mon Sep 17 00:00:00 2001
From: Sander Roosendaal
Date: Mon, 16 Oct 2017 07:36:41 +0200
Subject: [PATCH 2/4] replaced upload with export in upload page
---
rowers/forms.py | 12 ++++++------
rowers/templates/document_form.html | 2 +-
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/rowers/forms.py b/rowers/forms.py
index eecde602..1e9974e2 100644
--- a/rowers/forms.py
+++ b/rowers/forms.py
@@ -72,19 +72,19 @@ class UploadOptionsForm(forms.Form):
initial='timeplot',
label='Plot Type')
upload_to_C2 = forms.BooleanField(initial=False,required=False,
- label='Upload to Concept2 logbook')
+ label='Export to Concept2 logbook')
upload_to_Strava = forms.BooleanField(initial=False,required=False,
- label='Upload to Strava')
+ label='Export to Strava')
upload_to_SportTracks = forms.BooleanField(initial=False,required=False,
- label='Upload to SportTracks')
+ label='Export to SportTracks')
upload_to_RunKeeper = forms.BooleanField(initial=False,required=False,
- label='Upload to RunKeeper')
+ label='Export to RunKeeper')
upload_to_MapMyFitness = forms.BooleanField(initial=False,
required=False,
- label='Upload to MapMyFitness')
+ label='Export to MapMyFitness')
upload_to_TrainingPeaks = forms.BooleanField(initial=False,
required=False,
- label='Upload to TrainingPeaks')
+ label='Export to TrainingPeaks')
# do_physics = forms.BooleanField(initial=False,required=False,label='Power Estimate (OTW)')
makeprivate = forms.BooleanField(initial=False,required=False,
label='Make Workout Private')
diff --git a/rowers/templates/document_form.html b/rowers/templates/document_form.html
index 6c316df4..53a2c06d 100644
--- a/rowers/templates/document_form.html
+++ b/rowers/templates/document_form.html
@@ -36,7 +36,7 @@
You can select one static plot to be generated immediately for
- this workout. You can select to upload to major fitness
+ this workout. You can select to export to major fitness
platforms automatically.
If you check "make private", this workout will not be visible to your followers and will not show up in your teams' workouts list.
From 353aeb5ab3c47481f32bd4401edf8dd502b49bb5 Mon Sep 17 00:00:00 2001
From: Sander Roosendaal
Date: Tue, 17 Oct 2017 08:46:23 +0200
Subject: [PATCH 3/4] bugfix notes field intervaleditor
---
rowers/views.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/rowers/views.py b/rowers/views.py
index 3e7f3d38..160274bb 100644
--- a/rowers/views.py
+++ b/rowers/views.py
@@ -8191,7 +8191,7 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
#intervalstats = rowdata.allstats()
if s:
try:
- row.notes += u'{n} \n {s}'.format(
+ row.notes = u'{n} \n {s}'.format(
n = row.notes,
s = s
)
From 63f1895343d07d34fb9c9aaf1d50d11f2ed9280d Mon Sep 17 00:00:00 2001
From: Sander Roosendaal
Date: Tue, 17 Oct 2017 09:39:30 +0200
Subject: [PATCH 4/4] bar charts on team list by rower, not by type
---
rowers/interactiveplots.py | 11 +++++++----
rowers/views.py | 8 +++++++-
2 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/rowers/interactiveplots.py b/rowers/interactiveplots.py
index 2cc207c0..29675cd0 100644
--- a/rowers/interactiveplots.py
+++ b/rowers/interactiveplots.py
@@ -219,12 +219,13 @@ def interactive_boxchart(datadf,fieldname,extratitle=''):
return script,div
-def interactive_activitychart(workouts,startdate,enddate):
+def interactive_activitychart(workouts,startdate,enddate,stack='type'):
if len(workouts) == 0:
return "",""
dates = []
types = []
+ rowers = []
durations = []
for w in workouts:
@@ -234,6 +235,7 @@ def interactive_activitychart(workouts,startdate,enddate):
dates.append(dd)
durations.append(du)
types.append(w.workouttype)
+ rowers.append(w.user.user.first_name)
try:
d = utc.localize(startdate)
@@ -250,17 +252,18 @@ def interactive_activitychart(workouts,startdate,enddate):
dates.append(d.strftime('%m/%d'))
durations.append(0)
types.append('rower')
+ rowers.append('Sander')
d += datetime.timedelta(days=1)
-
df = pd.DataFrame({
'date':dates,
'duration':durations,
'type':types,
+ 'rower':rowers,
})
p = Bar(df,'date',values='duration',title='Activity',
- stack='type',
+ stack=stack,
plot_width=350,
plot_height=250,
toolbar_location = None,
@@ -270,7 +273,7 @@ def interactive_activitychart(workouts,startdate,enddate):
new_items = []
for legend_item in legend.items:
it = legend_item.label['value']
- tot = df[df['type']==it].duration.sum()
+ tot = df[df[stack]==it].duration.sum()
if tot != 0:
new_items.append(legend_item)
legend.items = new_items
diff --git a/rowers/views.py b/rowers/views.py
index 160274bb..208239cc 100644
--- a/rowers/views.py
+++ b/rowers/views.py
@@ -4416,9 +4416,15 @@ def workouts_view(request,message='',successmessage='',
"-id"
)
+ if theteam:
+ stack='rower'
+ else:
+ stack='type'
+
script,div = interactive_activitychart(g_workouts,
activity_startdate,
- activity_enddate)
+ activity_enddate,
+ stack=stack)
messages.info(request,successmessage)
messages.error(request,message)