Merge branch 'release/v13.25'
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -1,5 +1,6 @@
|
|||||||
from rowers.imports import *
|
from rowers.imports import *
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
from requests_oauthlib import OAuth1,OAuth1Session
|
from requests_oauthlib import OAuth1,OAuth1Session
|
||||||
from requests import Request, Session
|
from requests import Request, Session
|
||||||
@@ -18,6 +19,8 @@ from rowsandall_app.settings import (
|
|||||||
GARMIN_CLIENT_KEY, GARMIN_REDIRECT_URI, GARMIN_CLIENT_SECRET
|
GARMIN_CLIENT_KEY, GARMIN_REDIRECT_URI, GARMIN_CLIENT_SECRET
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from pytz import timezone as tz, utc
|
||||||
|
|
||||||
from rowers.tasks import handle_c2_import_stroke_data, handle_c2_sync
|
from rowers.tasks import handle_c2_import_stroke_data, handle_c2_sync
|
||||||
import django_rq
|
import django_rq
|
||||||
queue = django_rq.get_queue('default')
|
queue = django_rq.get_queue('default')
|
||||||
@@ -128,6 +131,11 @@ def get_garmin_workout_list(user):
|
|||||||
def garmin_getworkout(garminid,r,activity):
|
def garmin_getworkout(garminid,r,activity):
|
||||||
starttime = activity['startTimeInSeconds']
|
starttime = activity['startTimeInSeconds']
|
||||||
startdatetime = arrow.get(starttime)
|
startdatetime = arrow.get(starttime)
|
||||||
|
try:
|
||||||
|
offset = activity['startTimeOffsetInSeconds']
|
||||||
|
except KeyError:
|
||||||
|
offset = 0
|
||||||
|
print(offset)
|
||||||
durationseconds = activity['durationInSeconds']
|
durationseconds = activity['durationInSeconds']
|
||||||
duration = dataprep.totaltime_sec_to_string(durationseconds)
|
duration = dataprep.totaltime_sec_to_string(durationseconds)
|
||||||
activitytype = activity['activityType']
|
activitytype = activity['activityType']
|
||||||
@@ -148,15 +156,29 @@ def garmin_getworkout(garminid,r,activity):
|
|||||||
except Workout.DoesNotExist:
|
except Workout.DoesNotExist:
|
||||||
newcsvfile='media/garmin{code}_{importid}.csv'
|
newcsvfile='media/garmin{code}_{importid}.csv'
|
||||||
w = Workout(user=r,csvfilename=newcsvfile)
|
w = Workout(user=r,csvfilename=newcsvfile)
|
||||||
w.startdatetime = datetime.datetime(
|
|
||||||
|
utc_offset = datetime.timedelta(seconds=offset)
|
||||||
|
now = datetime.datetime.now(pytz.utc)
|
||||||
|
zones = [tz.zone for tz in map(pytz.timezone, pytz.all_timezones_set)
|
||||||
|
if now.astimezone(tz).utcoffset() == utc_offset]
|
||||||
|
if r.defaulttimezone in zones:
|
||||||
|
thetimezone = r.defaulttimezone
|
||||||
|
elif len(zones):
|
||||||
|
thetimezone = zones[0]
|
||||||
|
else:
|
||||||
|
thetimezone = utc
|
||||||
|
|
||||||
|
startdatetime = datetime.datetime(
|
||||||
year=startdatetime.year,
|
year=startdatetime.year,
|
||||||
month=startdatetime.month,
|
month=startdatetime.month,
|
||||||
day=startdatetime.day,
|
day=startdatetime.day,
|
||||||
hour=startdatetime.hour,
|
hour=startdatetime.hour,
|
||||||
minute=startdatetime.minute,
|
minute=startdatetime.minute,
|
||||||
second=startdatetime.second,
|
second=startdatetime.second,
|
||||||
tzinfo=startdatetime.tzinfo)
|
).astimezone(pytz.timezone(thetimezone))
|
||||||
w.starttime = startdatetime.time()
|
|
||||||
|
w.startdatetime = startdatetime
|
||||||
|
w.starttime = w.startdatetime.time()
|
||||||
try:
|
try:
|
||||||
w.duration = datetime.datetime.strptime(duration,"%H:%M:%S.%f").time()
|
w.duration = datetime.datetime.strptime(duration,"%H:%M:%S.%f").time()
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
|||||||
Reference in New Issue
Block a user