Private
Public Access
1
0

fixing c2 timezone stuff - hope it's better now

This commit is contained in:
Sander Roosendaal
2021-05-26 15:43:54 +02:00
parent d4d6ba5922
commit 9572a18263
8 changed files with 90 additions and 11 deletions

View File

@@ -9,6 +9,8 @@ from time import strftime
import requests
from rowers.utils import dologging
#https:#oauth-stage.nkrowlink.com/oauth/authorizegrant_type=authorization_code&response_type=code&client_id=rowsandall-staging&scope=read&state=fc8fc3d8-ce0a-443e-838a-1c06fb5317c6&redirect_uri=https%3A%2F%2Fdunav.ngrok.io%2Fnk_callback%2F
#https:#oauth-stage.nkrowlink.com/oauth/authorize?grant_type=authorization_code&response_type=code&client_id=rowsandall-staging&scope=read&state=1234&redirect_uri=https%3A%2F%2Fdev.rowsandall.com%2Fnk_callback
@@ -247,7 +249,7 @@ def get_nk_workout_list(user,fake=False,after=0,before=0):
#
def get_workout(user,nkid,do_async=True):
def get_workout(user,nkid,do_async=True,startdate='',enddate=''):
r = Rower.objects.get(user=user)
if (r.nktoken == '') or (r.nktoken is None): # pragma: no cover
s = "Token doesn't exist. Need to authorize"
@@ -260,8 +262,18 @@ def get_workout(user,nkid,do_async=True):
'sessionIds': nkid,
}
res = get_nk_workout_list(r.user)
before = 0
after = 0
if startdate:
startdate = arrow.get(startdate)
after = str(int(startdate.timestamp())*1000)
if enddate:
enddate = arrow.get(enddate)
before = str(int(enddate.timestamp())*1000)
res = get_nk_workout_list(r.user,before=before,after=after)
if res.status_code != 200: # pragma: no cover
# dologging('nklog.log','Status code {code}'.format(code=res.status_code))
return 0
alldata = {}
for item in res.json():