Private
Public Access
1
0

fixes icu

This commit is contained in:
2025-01-08 20:05:13 +01:00
parent 3a917354af
commit 44df1a6d79
7 changed files with 72 additions and 34 deletions

View File

@@ -169,7 +169,10 @@ class IntervalsIntegration(SyncIntegration):
def workout_export(self, workout, *args, **kwargs) -> str:
token = self.open()
try:
token = self.open()
except NoTokenError:
return 0
dologging('intervals.icu.log', "Exporting workout {id}".format(id=workout.id))
filename = self.createworkoutdata(workout)
@@ -220,6 +223,11 @@ class IntervalsIntegration(SyncIntegration):
return id
def get_workout_list(self, *args, **kwargs) -> int:
try:
token = self.open()
except NoTokenError:
return []
url = self.oauth_data['base_url'] + 'athlete/0/activities?'
startdate = timezone.now() - timedelta(days=30)
enddate = timezone.now() + timedelta(days=1)
@@ -238,7 +246,7 @@ class IntervalsIntegration(SyncIntegration):
url += 'oldest=' + startdate.strftime('%Y-%m-%d') + '&newest=' + enddate.strftime('%Y-%m-%d')
headers = {
'accept': '*/*',
'authorization': 'Bearer ' + self.open(),
'authorization': 'Bearer ' + token
}
response = requests.get(url, headers=headers)
@@ -278,7 +286,10 @@ class IntervalsIntegration(SyncIntegration):
return workouts
def update_workout(self, id, *args, **kwargs) -> int:
_ = self.open()
try:
_ = self.open()
except NoTokenError:
return 0
r = self.rower
headers = {
@@ -308,8 +319,10 @@ class IntervalsIntegration(SyncIntegration):
pass
try:
w.rpe = data['icu_rpe']
if w.rpe is None:
w.rpe = 0
except KeyError:
pass
w.rpe = 0
try:
w.is_commute = data['commute']
if w.is_commute is None:
@@ -387,7 +400,11 @@ class IntervalsIntegration(SyncIntegration):
return 1
def get_workout(self, id, *args, **kwargs) -> int:
_ = self.open()
try:
_ = self.open()
except NoTokenError:
return 0
r = self.rower
do_async = kwargs.get('do_async', True)
@@ -506,7 +523,7 @@ class IntervalsIntegration(SyncIntegration):
return 1
def pair_workout_and_session(w, id):
def pair_workout_and_session(self, w, id):
pass
@@ -541,7 +558,11 @@ class IntervalsIntegration(SyncIntegration):
return super(IntervalsIntegration, self).token_refresh(*args, **kwargs)
def get_plannedsessions_list(self, *args, **kwargs):
_ = self.open()
try:
_ = self.open()
except NoTokenError:
return []
r = self.rower
headers = {
@@ -562,7 +583,11 @@ class IntervalsIntegration(SyncIntegration):
return data
def update_plannedsession(self, ps, data, *args, **kwargs):
_ = self.open()
try:
_ = self.open()
except NoTokenError:
return 0
r = self.rower
if data['category'] == 'WORKOUT':
@@ -584,7 +609,11 @@ class IntervalsIntegration(SyncIntegration):
return data
def get_plannedsession(self, id, *args, **kwargs):
_ = self.open()
try:
_ = self.open()
except NoTokenError:
return 0
r = self.rower
url = self.oauth_data['base_url'] + 'athlete/0/events/' + str(id)
@@ -618,7 +647,11 @@ class IntervalsIntegration(SyncIntegration):
return data
def plannedsession_create(self, ps, *args, **kwargs):
_ = self.open()
try:
_ = self.open()
except NoTokenError:
return 0
r = self.rower
headers = {
@@ -626,6 +659,7 @@ class IntervalsIntegration(SyncIntegration):
}
stepstext = ps.steps_intervals()
print(stepstext)
category = 'WORKOUT'
startdate = ps.preferreddate.strftime('%Y-%m-%dT%H:%M:%S')
@@ -671,7 +705,11 @@ class IntervalsIntegration(SyncIntegration):
return id
def plannedsession_delete(self, ps, *args, **kwargs):
_ = self.open()
try:
_ = self.open()
except NoTokenError:
return 0
r = self.rower
headers = {
@@ -750,9 +788,12 @@ class IntervalsIntegration(SyncIntegration):
ps.sessionvalue = timetarget
ps.save()
if data['category'].lower() == 'workout':
ps.fitfile = data['fitfile']
ps.save()
ps.update_steps()
try:
ps.fitfile = data['fitfile']
ps.save()
ps.update_steps()
except KeyError:
pass
if data['category'].lower() == 'target':
ps.sessiontype = 'cycletarget'
ps.sessionvalue = int(data['time_target'])/60.