Merge branch 'release/v6.71'
This commit is contained in:
@@ -318,9 +318,9 @@
|
||||
|
||||
{% if workouts.has_next %}
|
||||
{% if request.GET.q %}
|
||||
<a class="wh" href="?page={{ workouts.next_page_number }}&q={{ request.GET.q }}">></a>
|
||||
<a class="wh" href="{{ startdate|date:"Y-m-d" }}/{{ enddate|date:"Y-m-d" }}?page={{ workouts.next_page_number }}&q={{ request.GET.q }}">></a>
|
||||
{% else %}
|
||||
<a class="wh" href="?page={{ workouts.next_page_number }}">></a>
|
||||
<a class="wh" href="{{ startdate|date:"Y-m-d" }}/{{ enddate|date:"Y-m-d" }}?page={{ workouts.next_page_number }}">></a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</span>
|
||||
|
||||
+36
-12
@@ -9,6 +9,7 @@ import requests.auth
|
||||
import json
|
||||
from django.utils import timezone
|
||||
from datetime import datetime,timedelta
|
||||
import arrow
|
||||
import numpy as np
|
||||
from dateutil import parser
|
||||
import time
|
||||
@@ -239,7 +240,11 @@ def createunderarmourworkoutdata(w):
|
||||
except:
|
||||
return 0
|
||||
|
||||
st = w.startdatetime.astimezone(pytz.timezone(w.timezone))
|
||||
start_time = st.isoformat()
|
||||
|
||||
averagehr = int(row.df[' HRCur (bpm)'].mean())
|
||||
averagespm = int(row.df[' Cadence (stokes/min)'].mean()/2.)
|
||||
maxhr = int(row.df[' HRCur (bpm)'].max())
|
||||
duration = w.duration.hour*3600
|
||||
duration += w.duration.minute*60
|
||||
@@ -253,31 +258,42 @@ def createunderarmourworkoutdata(w):
|
||||
|
||||
# adding diff, trying to see if this is valid
|
||||
#t = row.df.ix[:,'TimeStamp (sec)'].values-10*row.df.ix[0,'TimeStamp (sec)']
|
||||
t = row.df.ix[:,'TimeStamp (sec)'].values-row.df.ix[0,'TimeStamp (sec)']
|
||||
t[0] = t[1]
|
||||
t = row.df.ix[:,'TimeStamp (sec)'].values #-row.df.ix[0,'TimeStamp (sec)']
|
||||
|
||||
# t += arrow.get(st).timestamp
|
||||
|
||||
# t[0] = t[1]
|
||||
|
||||
d = row.df.ix[:,'cum_dist'].values
|
||||
d[0] = d[1]
|
||||
t = t.astype(int)
|
||||
t = t.astype(float)
|
||||
|
||||
|
||||
|
||||
|
||||
d = d.astype(int)
|
||||
spm = row.df[' Cadence (stokes/min)'].astype(int)
|
||||
spm[0] = spm[1]
|
||||
hr = row.df[' HRCur (bpm)'].astype(int)
|
||||
speed = row.df[' AverageBoatSpeed (m/s)']
|
||||
speed = speed.replace(np.inf,0)
|
||||
|
||||
haslatlon=1
|
||||
|
||||
try:
|
||||
lat = row.df[' latitude'].values
|
||||
lon = row.df[' longitude'].values
|
||||
lat = row.df[' latitude']
|
||||
lon = row.df[' longitude']
|
||||
if not lat.std() and not lon.std():
|
||||
haslatlon = 0
|
||||
except KeyError:
|
||||
haslatlon = 0
|
||||
|
||||
|
||||
|
||||
# path data
|
||||
if haslatlon:
|
||||
locdata = []
|
||||
for e in zip(t,lat,lon):
|
||||
for e in zip(t,lat.values,lon.values):
|
||||
point = {
|
||||
'lat':e[1],
|
||||
'lng':e[2],
|
||||
@@ -303,8 +319,6 @@ def createunderarmourworkoutdata(w):
|
||||
for e in zip(t,spm):
|
||||
spmdata.append([e[0],e[1]])
|
||||
|
||||
st = w.startdatetime.astimezone(pytz.timezone(w.timezone))
|
||||
start_time = st.isoformat()
|
||||
|
||||
timeseries = {
|
||||
"distance": distancedata,
|
||||
@@ -312,22 +326,32 @@ def createunderarmourworkoutdata(w):
|
||||
"cadence": spmdata,
|
||||
}
|
||||
|
||||
aggregrates = {
|
||||
|
||||
aggregates = {
|
||||
"elapsed_time_total": int(duration),
|
||||
"active_time_total": int(duration),
|
||||
"distance_total": int(max(d)),
|
||||
"heartrate_avg": averagehr,
|
||||
"heart_rate_min": int(min(hr)),
|
||||
"heart_rate_max": int(max(hr)),
|
||||
"speed_min": speed.min().astype(float),
|
||||
"speed_max": speed.max().astype(float),
|
||||
"speed_avg": speed.mean(),
|
||||
"cadence_min": int(min(spm)/2.),
|
||||
"cadence_max": int(max(spm)/2.),
|
||||
"cadence_avg": averagespm,
|
||||
}
|
||||
|
||||
|
||||
# if haslatlon:
|
||||
# timeseries["position"] = locdata
|
||||
if haslatlon:
|
||||
timeseries["position"] = locdata
|
||||
|
||||
data = {
|
||||
"name": name,
|
||||
"start_datetime": start_time,
|
||||
"name": name,
|
||||
"has_time_series": True,
|
||||
"time_series": timeseries,
|
||||
"aggregates": aggregates,
|
||||
"start_locale_timezone": "Etc/UTC",
|
||||
"activity_type": "/v7.1/activity_type/128/",
|
||||
"notes": notes,
|
||||
|
||||
+11
-7
@@ -2242,7 +2242,6 @@ def workout_underarmour_upload_view(request,id=0):
|
||||
|
||||
if (checkworkoutuser(request.user,w)):
|
||||
data = underarmourstuff.createunderarmourworkoutdata(w)
|
||||
# return HttpResponse(json.dumps(data))
|
||||
if not data:
|
||||
message = "Data error"
|
||||
messages.error(request,message)
|
||||
@@ -2262,6 +2261,7 @@ def workout_underarmour_upload_view(request,id=0):
|
||||
url = "https://api.ua.com/v7.1/workout/"
|
||||
response = requests.post(url,headers=headers,data=json.dumps(data))
|
||||
|
||||
|
||||
# check for duplicate error first
|
||||
if (response.status_code == 409 ):
|
||||
message = "Duplicate error"
|
||||
@@ -2276,7 +2276,7 @@ def workout_underarmour_upload_view(request,id=0):
|
||||
return HttpResponseRedirect(url)
|
||||
else:
|
||||
s = response
|
||||
message = "Something went wrong in workout_underarmour_upload_view: %s - %s" % (s.reason,s.text)
|
||||
message = "Something went wrong in workout_underarmour_upload_view: %s " % s.reason
|
||||
messages.error(request,message)
|
||||
else:
|
||||
message = "You are not authorized to upload this workout"
|
||||
@@ -7091,7 +7091,7 @@ def workout_downloadmetar_view(request,id=0,
|
||||
|
||||
starttimeunix = arrow.get(row.startdatetime).timestamp
|
||||
#starttimeunix = int(mktime(startdatetime.utctimetuple()))
|
||||
avgtime = starttimeunix+avgtime
|
||||
avgtime = starttimeunix +avgtime
|
||||
winddata = get_metar_data(airportcode,avgtime)
|
||||
windspeed = winddata[0]
|
||||
windbearing = winddata[1]
|
||||
@@ -9077,11 +9077,15 @@ def workout_edit_view(request,id=0,message="",successmessage=""):
|
||||
except KeyError:
|
||||
rankingpiece =- Workout.objects.get(id=id).rankingpiece
|
||||
|
||||
startdatetime = (str(date) + ' ' + str(starttime))
|
||||
startdatetime = datetime.datetime.strptime(startdatetime,
|
||||
"%Y-%m-%d %H:%M:%S")
|
||||
startdatetime = datetime.datetime.combine(
|
||||
date,starttime
|
||||
)
|
||||
|
||||
startdatetime = startdatetime.replace(tzinfo=pytz.timezone(thetimezone))
|
||||
startdatetime = pytz.timezone(thetimezone).localize(
|
||||
startdatetime
|
||||
)
|
||||
|
||||
print startdatetime
|
||||
try:
|
||||
# aware object can be in any timezone
|
||||
out = startdatetime.astimezone(pytz.utc)
|
||||
|
||||
@@ -45,6 +45,7 @@ def get_metar_data(airportcode,unixtime):
|
||||
url += str(unixtime+3600)
|
||||
url += "&stationString="+airportcode
|
||||
|
||||
|
||||
try:
|
||||
s = requests.get(url)
|
||||
except:
|
||||
|
||||
Reference in New Issue
Block a user