c2stuff.create_async_workout start
works but is not async yet
This commit is contained in:
@@ -32,7 +32,8 @@ from utils import deserialize_list
|
||||
from rowers.dataprepnodjango import (
|
||||
update_strokedata, new_workout_from_file,
|
||||
getsmallrowdata_db, updatecpdata_sql,
|
||||
update_agegroup_db,fitnessmetric_to_sql
|
||||
update_agegroup_db,fitnessmetric_to_sql,
|
||||
add_c2_stroke_data_db
|
||||
)
|
||||
|
||||
from django.core.mail import send_mail, EmailMessage
|
||||
@@ -40,8 +41,9 @@ from django.db.utils import OperationalError
|
||||
|
||||
import datautils
|
||||
import utils
|
||||
|
||||
import requests
|
||||
import longtask
|
||||
import arrow
|
||||
|
||||
# testing task
|
||||
|
||||
@@ -50,6 +52,33 @@ import longtask
|
||||
def add(x, y):
|
||||
return x + y
|
||||
|
||||
|
||||
@app.task
|
||||
def handle_c2_import_stroke_data(c2token,
|
||||
c2id,workoutid,
|
||||
startdatetime,
|
||||
csvfilename,debug=True):
|
||||
authorizationstring = str('Bearer ' + c2token)
|
||||
headers = {'Authorization': authorizationstring,
|
||||
'user-agent': 'sanderroosendaal',
|
||||
'Content-Type': 'application/json'}
|
||||
url = "https://log.concept2.com/api/users/me/results/"+str(c2id)+"/strokes"
|
||||
s = requests.get(url,headers=headers)
|
||||
if s.status_code == 200:
|
||||
strokedata = pd.DataFrame.from_dict(s.json()['data'])
|
||||
starttimeunix = arrow.get(startdatetime).timestamp
|
||||
result = add_c2_stroke_data_db(
|
||||
strokedata,workoutid,starttimeunix,
|
||||
csvfilename,debug=debug,
|
||||
)
|
||||
|
||||
|
||||
return 1
|
||||
else:
|
||||
return 0
|
||||
|
||||
return 0
|
||||
|
||||
def getagegrouprecord(age,sex='male',weightcategory='hwt',
|
||||
distance=2000,duration=None,indf=pd.DataFrame()):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user