import without stroke data now works
This commit is contained in:
@@ -13,6 +13,9 @@ import rowingdata
|
||||
from rowingdata import rowingdata as rdata
|
||||
|
||||
from celery import app
|
||||
import datetime
|
||||
import pytz
|
||||
import iso8601
|
||||
|
||||
from matplotlib.backends.backend_agg import FigureCanvas
|
||||
#from matplotlib.backends.backend_cairo import FigureCanvasCairo as FigureCanvas
|
||||
@@ -33,7 +36,8 @@ from rowers.dataprepnodjango import (
|
||||
update_strokedata, new_workout_from_file,
|
||||
getsmallrowdata_db, updatecpdata_sql,
|
||||
update_agegroup_db,fitnessmetric_to_sql,
|
||||
add_c2_stroke_data_db
|
||||
add_c2_stroke_data_db,totaltime_sec_to_string,
|
||||
create_c2_stroke_data_db
|
||||
)
|
||||
|
||||
from django.core.mail import send_mail, EmailMessage
|
||||
@@ -71,9 +75,47 @@ def handle_c2_import_stroke_data(c2token,
|
||||
csvfilename,debug=debug,
|
||||
)
|
||||
|
||||
|
||||
return 1
|
||||
else:
|
||||
url = "https://log.concept2.com/api/users/me/results/"+str(c2id)
|
||||
s = requests.get(url,headers=headers)
|
||||
|
||||
if s.status_code == 200:
|
||||
workoutdata = s.json()['data']
|
||||
distance = workoutdata['distance']
|
||||
c2id = workoutdata['id']
|
||||
workouttype = workoutdata['type']
|
||||
verified = workoutdata['verified']
|
||||
startdatetime = iso8601.parse_date(workoutdata['date'])
|
||||
weightclass = workoutdata['weight_class']
|
||||
weightcategory = 'hwt'
|
||||
if weightclass == "L":
|
||||
weightcategory = 'lwt'
|
||||
totaltime = workoutdata['time']/10.
|
||||
duration = totaltime_sec_to_string(totaltime)
|
||||
duration = datetime.datetime.strptime(duration,'%H:%M:%S.%f').time()
|
||||
|
||||
try:
|
||||
timezone_str = tz(workoutdata['timezone'])
|
||||
except:
|
||||
timezone_str = 'UTC'
|
||||
|
||||
workoutdate = startdatetime.astimezone(
|
||||
pytz.timezone(timezone_str)
|
||||
).strftime('%Y-%m-%d')
|
||||
starttime = startdatetime.astimezone(
|
||||
pytz.timezone(timezone_str)
|
||||
).strftime('%H:%M:%S')
|
||||
|
||||
result = create_c2_stroke_data_db(
|
||||
distance,duration,workouttype,
|
||||
workoutid,starttimeunix,
|
||||
csvfilename,debug=debug,
|
||||
)
|
||||
|
||||
|
||||
return 1
|
||||
|
||||
return 0
|
||||
|
||||
return 0
|
||||
|
||||
Reference in New Issue
Block a user