Private
Public Access
1
0

more changes

This commit is contained in:
2024-12-09 20:20:32 +01:00
parent 53e6fefbfe
commit 179361835b
5 changed files with 88 additions and 14 deletions

View File

@@ -1367,6 +1367,7 @@ def get_workouttype_from_fit(filename, workouttype='water'):
return 'water'
try:
workouttype = mytypes.fitmappinginv[fittype]
return workouttype
except KeyError: # pragma: no cover
return workouttype

View File

@@ -1172,6 +1172,8 @@ class Rower(models.Model):
default='', max_length=200, blank=True, null=True)
c2_auto_export = models.BooleanField(default=False)
c2_auto_import = models.BooleanField(default=False)
intervals_auto_export = models.BooleanField(default=False)
intervals_auto_import = models.BooleanField(default=False)
sporttrackstoken = models.CharField(
default='', max_length=200, blank=True, null=True)
sporttrackstokenexpirydate = models.DateTimeField(blank=True, null=True)
@@ -3827,6 +3829,7 @@ class TombStone(models.Model):
uploadedtosporttracks = models.BigIntegerField(default=0)
uploadedtotp = models.BigIntegerField(default=0)
uploadedtonk = models.BigIntegerField(default=0)
uploadedtointervals = models.BigIntegerField(default=0)
@receiver(models.signals.pre_delete, sender=Workout)
def create_tombstone_on_delete(sender, instance, **kwargs):
@@ -3835,7 +3838,8 @@ def create_tombstone_on_delete(sender, instance, **kwargs):
uploadedtoc2=instance.uploadedtoc2,
uploadedtostrava=instance.uploadedtostrava,
uploadedtotp=instance.uploadedtotp,
uploadedtonk=instance.uploadedtonk
uploadedtonk=instance.uploadedtonk,
uploadedtointervals=instance.uploadedtointervals,
)
t.save()

View File

@@ -180,6 +180,41 @@ fitcollection = (
fitmapping = {key: value for key, value in Reverse(fitcollection)}
intervalscollection = (
('water', 'Rowing'),
('rower', 'VirtualRow'),
('skierg', 'NordicSki'),
('bike', 'Ride'),
('bikeerg', 'VirtualRide'),
('dynamic', 'Rowing'),
('slides', 'Rowing'),
('paddle', 'StandUpPaddling'),
('snow', 'NordicSki'),
('coastal', 'Rowing'),
('c-boat', 'Rowing'),
('churchboat', 'Rowing'),
('Ride', 'Ride'),
('Run', 'Run'),
('NordicSki', 'NordicSki'),
('Swim', 'Swim'),
('Hike', 'Hike'),
('Walk', 'Walk'),
('Canoeing', 'Canoeing'),
('Crossfit', 'Crossfit'),
('StandUpPaddling', 'StandUpPaddling'),
('IceSkate', 'IceSkate'),
('WeightTraining', 'WeightTraining'),
('InlineSkate', 'InlineSkate'),
('Kayaking', 'Kayaking'),
('Workout', 'Workout'),
('Yoga', 'Yoga'),
('other', 'Other'),
)
intervalsmapping = {key: value for key, value in Reverse(intervalscollection)}
stcollection = (
('water', 'Rowing'),
('rower', 'Rowing'),
@@ -332,6 +367,9 @@ garminmappinginv = {value: key for key, value in Reverse(
fitmappinginv = {value: key for key, value in Reverse(
fitcollection) if value is not None}
intervalsmappinginv = {value: key for key, value in Reverse(
intervalscollection) if value is not None}
otwtypes = (
'water',
'coastal',

View File

@@ -24,7 +24,7 @@ from rowers.courseutils import (
InvalidTrajectoryError
)
from rowers.emails import send_template_email
from rowers.mytypes import fitmappinginv
from rowers.mytypes import intervalsmappinginv
from rowers.nkimportutils import (
get_nk_summary, get_nk_allstats, get_nk_intervalstats, getdict, strokeDataToDf,
add_workout_from_data
@@ -3508,11 +3508,11 @@ def handle_intervals_getworkout(rower, intervalstoken, workoutid, debug=False, *
title = 'Intervals workout'
try:
workouttype = fitmappinginv[data['type']]
print(data['type'])
workouttype = intervalsmappinginv[data['type']]
except KeyError:
workouttype = 'water'
url = "https://intervals.icu/api/v1/activity/{workoutid}/fit-file".format(workoutid=workoutid)
response = requests.get(url, headers=headers)
@@ -3535,7 +3535,6 @@ def handle_intervals_getworkout(rower, intervalstoken, workoutid, debug=False, *
duration = totaltime_sec_to_string(rowdata.duration)
distance = rowdata.df[" Horizontal (meters)"].iloc[-1]
except Exception as e:
print(e)
return 0
uploadoptions = {
@@ -3544,6 +3543,7 @@ def handle_intervals_getworkout(rower, intervalstoken, workoutid, debug=False, *
'boattype': '1x',
'workouttype': workouttype,
'file': fit_filename,
'intervalsid': intervalsid,
'title': title,
'rpe': 0,
'notes': '',

View File

@@ -146,6 +146,22 @@ def do_sync(w, options, quick=False):
except KeyError:
pass
do_icu_export = w.user.intervals_auto_export
try:
do_icu_export = options['upload_to_Intervals'] or do_icu_export
except KeyError:
pass
try:
if options['intervalsid'] != 0 and options['intervalsid'] != '': # pragma: no cover
w.uploadedtointervals = options['intervalsid']
# upload_to_icu = False
do_icu_export = False
w.save()
record = create_or_update_syncrecord(w.user, w, intervalsid=options['intervalsid'])
except KeyError:
pass
try:
if options['nkid'] != 0 and options['nkid'] != '': # pragma: no cover
w.uploadedtonk = options['nkid']
@@ -232,14 +248,29 @@ def do_sync(w, options, quick=False):
except NoTokenError: # pragma: no cover
id = 0
message = "Please connect to Strava first"
except:
e = sys.exc_info()[0]
t = time.localtime()
timestamp = time.strftime('%b-%d-%Y_%H%M', t)
with open('stravalog.log', 'a') as f:
f.write('\n')
f.write(timestamp)
f.write(str(e))
except Exception as e:
dologging('stravalog.log', e)
if do_icu_export:
intervals_integration = IntervalsIntegration(w.user.user)
try:
id = intervals_integration.workout_export(w)
dologging(
'intervals.icu.log',
'exporting workout {id} as {type}'.format(
id=w.id,
type=w.workouttype,
)
)
except NoTokenError:
id = 0
message = "Please connect to Intervals.icu first"
except Exception as e:
dologging(
'intervals.icu.log',
e
)
do_st_export = w.user.sporttracks_auto_export