more changes
This commit is contained in:
@@ -1367,6 +1367,7 @@ def get_workouttype_from_fit(filename, workouttype='water'):
|
|||||||
return 'water'
|
return 'water'
|
||||||
try:
|
try:
|
||||||
workouttype = mytypes.fitmappinginv[fittype]
|
workouttype = mytypes.fitmappinginv[fittype]
|
||||||
|
return workouttype
|
||||||
except KeyError: # pragma: no cover
|
except KeyError: # pragma: no cover
|
||||||
return workouttype
|
return workouttype
|
||||||
|
|
||||||
|
|||||||
@@ -1172,6 +1172,8 @@ class Rower(models.Model):
|
|||||||
default='', max_length=200, blank=True, null=True)
|
default='', max_length=200, blank=True, null=True)
|
||||||
c2_auto_export = models.BooleanField(default=False)
|
c2_auto_export = models.BooleanField(default=False)
|
||||||
c2_auto_import = 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(
|
sporttrackstoken = models.CharField(
|
||||||
default='', max_length=200, blank=True, null=True)
|
default='', max_length=200, blank=True, null=True)
|
||||||
sporttrackstokenexpirydate = models.DateTimeField(blank=True, null=True)
|
sporttrackstokenexpirydate = models.DateTimeField(blank=True, null=True)
|
||||||
@@ -3827,6 +3829,7 @@ class TombStone(models.Model):
|
|||||||
uploadedtosporttracks = models.BigIntegerField(default=0)
|
uploadedtosporttracks = models.BigIntegerField(default=0)
|
||||||
uploadedtotp = models.BigIntegerField(default=0)
|
uploadedtotp = models.BigIntegerField(default=0)
|
||||||
uploadedtonk = models.BigIntegerField(default=0)
|
uploadedtonk = models.BigIntegerField(default=0)
|
||||||
|
uploadedtointervals = models.BigIntegerField(default=0)
|
||||||
|
|
||||||
@receiver(models.signals.pre_delete, sender=Workout)
|
@receiver(models.signals.pre_delete, sender=Workout)
|
||||||
def create_tombstone_on_delete(sender, instance, **kwargs):
|
def create_tombstone_on_delete(sender, instance, **kwargs):
|
||||||
@@ -3835,7 +3838,8 @@ def create_tombstone_on_delete(sender, instance, **kwargs):
|
|||||||
uploadedtoc2=instance.uploadedtoc2,
|
uploadedtoc2=instance.uploadedtoc2,
|
||||||
uploadedtostrava=instance.uploadedtostrava,
|
uploadedtostrava=instance.uploadedtostrava,
|
||||||
uploadedtotp=instance.uploadedtotp,
|
uploadedtotp=instance.uploadedtotp,
|
||||||
uploadedtonk=instance.uploadedtonk
|
uploadedtonk=instance.uploadedtonk,
|
||||||
|
uploadedtointervals=instance.uploadedtointervals,
|
||||||
)
|
)
|
||||||
t.save()
|
t.save()
|
||||||
|
|
||||||
|
|||||||
@@ -180,6 +180,41 @@ fitcollection = (
|
|||||||
|
|
||||||
fitmapping = {key: value for key, value in Reverse(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 = (
|
stcollection = (
|
||||||
('water', 'Rowing'),
|
('water', 'Rowing'),
|
||||||
('rower', 'Rowing'),
|
('rower', 'Rowing'),
|
||||||
@@ -332,6 +367,9 @@ garminmappinginv = {value: key for key, value in Reverse(
|
|||||||
fitmappinginv = {value: key for key, value in Reverse(
|
fitmappinginv = {value: key for key, value in Reverse(
|
||||||
fitcollection) if value is not None}
|
fitcollection) if value is not None}
|
||||||
|
|
||||||
|
intervalsmappinginv = {value: key for key, value in Reverse(
|
||||||
|
intervalscollection) if value is not None}
|
||||||
|
|
||||||
otwtypes = (
|
otwtypes = (
|
||||||
'water',
|
'water',
|
||||||
'coastal',
|
'coastal',
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ from rowers.courseutils import (
|
|||||||
InvalidTrajectoryError
|
InvalidTrajectoryError
|
||||||
)
|
)
|
||||||
from rowers.emails import send_template_email
|
from rowers.emails import send_template_email
|
||||||
from rowers.mytypes import fitmappinginv
|
from rowers.mytypes import intervalsmappinginv
|
||||||
from rowers.nkimportutils import (
|
from rowers.nkimportutils import (
|
||||||
get_nk_summary, get_nk_allstats, get_nk_intervalstats, getdict, strokeDataToDf,
|
get_nk_summary, get_nk_allstats, get_nk_intervalstats, getdict, strokeDataToDf,
|
||||||
add_workout_from_data
|
add_workout_from_data
|
||||||
@@ -3508,11 +3508,11 @@ def handle_intervals_getworkout(rower, intervalstoken, workoutid, debug=False, *
|
|||||||
title = 'Intervals workout'
|
title = 'Intervals workout'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
workouttype = fitmappinginv[data['type']]
|
workouttype = intervalsmappinginv[data['type']]
|
||||||
print(data['type'])
|
|
||||||
except KeyError:
|
except KeyError:
|
||||||
workouttype = 'water'
|
workouttype = 'water'
|
||||||
|
|
||||||
|
|
||||||
url = "https://intervals.icu/api/v1/activity/{workoutid}/fit-file".format(workoutid=workoutid)
|
url = "https://intervals.icu/api/v1/activity/{workoutid}/fit-file".format(workoutid=workoutid)
|
||||||
|
|
||||||
response = requests.get(url, headers=headers)
|
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)
|
duration = totaltime_sec_to_string(rowdata.duration)
|
||||||
distance = rowdata.df[" Horizontal (meters)"].iloc[-1]
|
distance = rowdata.df[" Horizontal (meters)"].iloc[-1]
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
uploadoptions = {
|
uploadoptions = {
|
||||||
@@ -3544,6 +3543,7 @@ def handle_intervals_getworkout(rower, intervalstoken, workoutid, debug=False, *
|
|||||||
'boattype': '1x',
|
'boattype': '1x',
|
||||||
'workouttype': workouttype,
|
'workouttype': workouttype,
|
||||||
'file': fit_filename,
|
'file': fit_filename,
|
||||||
|
'intervalsid': intervalsid,
|
||||||
'title': title,
|
'title': title,
|
||||||
'rpe': 0,
|
'rpe': 0,
|
||||||
'notes': '',
|
'notes': '',
|
||||||
|
|||||||
@@ -146,6 +146,22 @@ def do_sync(w, options, quick=False):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
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:
|
try:
|
||||||
if options['nkid'] != 0 and options['nkid'] != '': # pragma: no cover
|
if options['nkid'] != 0 and options['nkid'] != '': # pragma: no cover
|
||||||
w.uploadedtonk = options['nkid']
|
w.uploadedtonk = options['nkid']
|
||||||
@@ -232,14 +248,29 @@ def do_sync(w, options, quick=False):
|
|||||||
except NoTokenError: # pragma: no cover
|
except NoTokenError: # pragma: no cover
|
||||||
id = 0
|
id = 0
|
||||||
message = "Please connect to Strava first"
|
message = "Please connect to Strava first"
|
||||||
except:
|
except Exception as e:
|
||||||
e = sys.exc_info()[0]
|
dologging('stravalog.log', e)
|
||||||
t = time.localtime()
|
|
||||||
timestamp = time.strftime('%b-%d-%Y_%H%M', t)
|
if do_icu_export:
|
||||||
with open('stravalog.log', 'a') as f:
|
intervals_integration = IntervalsIntegration(w.user.user)
|
||||||
f.write('\n')
|
try:
|
||||||
f.write(timestamp)
|
id = intervals_integration.workout_export(w)
|
||||||
f.write(str(e))
|
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
|
do_st_export = w.user.sporttracks_auto_export
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user