adding async option to NK import
This commit is contained in:
@@ -247,7 +247,7 @@ def get_nk_workout_list(user,fake=False,after=0,before=0):
|
||||
|
||||
#
|
||||
|
||||
def get_workout(user,nkid):
|
||||
def get_workout(user,nkid,do_async=False):
|
||||
r = Rower.objects.get(user=user)
|
||||
if (r.nktoken == '') or (r.nktoken is None):
|
||||
s = "Token doesn't exist. Need to authorize"
|
||||
@@ -260,6 +260,27 @@ def get_workout(user,nkid):
|
||||
'sessionIds': nkid,
|
||||
}
|
||||
|
||||
if do_async:
|
||||
res = get_nk_workout_list(r.user)
|
||||
if res.status_code != 200:
|
||||
return 0
|
||||
alldata = {}
|
||||
for item in res.json():
|
||||
alldata[item['id']] = item
|
||||
|
||||
res = myqueue(
|
||||
queuehigh,
|
||||
handle_nk_async_workout,
|
||||
alldata,
|
||||
r.user.id,
|
||||
r.nktoken,
|
||||
nkid,
|
||||
0,
|
||||
r.defaulttimezone,
|
||||
)
|
||||
|
||||
return {},pd.DataFrame()
|
||||
|
||||
|
||||
authorizationstring = str('Bearer ' + r.nktoken)
|
||||
headers = {'Authorization': authorizationstring,
|
||||
@@ -292,7 +313,6 @@ def get_workout(user,nkid):
|
||||
before = before+timedelta(days=1)
|
||||
before = str(int(before.timestamp())*1000)
|
||||
after = str(int(after.timestamp())*1000)
|
||||
print(after)
|
||||
|
||||
|
||||
url = NK_API_LOCATION+"api/v1/sessions/"
|
||||
|
||||
Reference in New Issue
Block a user