ds
This commit is contained in:
@@ -15,7 +15,6 @@ import pytz
|
||||
|
||||
from rowsandall_app.settings import (
|
||||
C2_CLIENT_ID, C2_REDIRECT_URI, C2_CLIENT_SECRET,
|
||||
UPLOAD_SERVICE_URL, UPLOAD_SERVICE_SECRET
|
||||
)
|
||||
|
||||
from rowers.tasks import (
|
||||
|
||||
@@ -26,7 +26,6 @@ from rowers.opaque import encoder
|
||||
|
||||
from rowsandall_app.settings import (
|
||||
INTERVALS_CLIENT_ID, INTERVALS_REDIRECT_URI, INTERVALS_CLIENT_SECRET, SITE_URL,
|
||||
UPLOAD_SERVICE_SECRET, UPLOAD_SERVICE_URL
|
||||
)
|
||||
|
||||
import django_rq
|
||||
@@ -57,6 +56,7 @@ intervals_token_url = 'https://intervals.icu/api/oauth/token'
|
||||
webhookverification = 'JA9Vt6RNH10'
|
||||
|
||||
class IntervalsIntegration(SyncIntegration):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(IntervalsIntegration, self).__init__(*args, **kwargs)
|
||||
self.oauth_data = {
|
||||
@@ -315,6 +315,7 @@ class IntervalsIntegration(SyncIntegration):
|
||||
return workouts
|
||||
|
||||
def update_workout(self, id, *args, **kwargs) -> int:
|
||||
from rowers.dataflow import upload_handler
|
||||
try:
|
||||
_ = self.open()
|
||||
except NoTokenError:
|
||||
@@ -419,7 +420,6 @@ class IntervalsIntegration(SyncIntegration):
|
||||
|
||||
|
||||
uploadoptions = {
|
||||
'secret': UPLOAD_SERVICE_SECRET,
|
||||
'user': self.rower.user.id,
|
||||
'boattype': '1x',
|
||||
'workouttype': w.workouttype,
|
||||
@@ -427,8 +427,8 @@ class IntervalsIntegration(SyncIntegration):
|
||||
'intervalsid': id,
|
||||
'id': w.id,
|
||||
}
|
||||
url = UPLOAD_SERVICE_URL
|
||||
response = requests.post(url, data=uploadoptions)
|
||||
|
||||
response = upload_handler(uploadoptions, temp_filename)
|
||||
except FileNotFoundError:
|
||||
return 0
|
||||
except Exception as e:
|
||||
@@ -443,6 +443,7 @@ class IntervalsIntegration(SyncIntegration):
|
||||
return 1
|
||||
|
||||
def get_workout(self, id, *args, **kwargs) -> int:
|
||||
from rowers.dataflow import upload_handler
|
||||
try:
|
||||
_ = self.open()
|
||||
except NoTokenError:
|
||||
@@ -542,8 +543,17 @@ class IntervalsIntegration(SyncIntegration):
|
||||
except:
|
||||
return 0
|
||||
|
||||
w = Workout(
|
||||
user=r,
|
||||
name=title,
|
||||
workoutsource='intervals.icu',
|
||||
workouttype=workouttype,
|
||||
duration=duration,
|
||||
distance=distance,
|
||||
intervalsid=id,
|
||||
)
|
||||
|
||||
uploadoptions = {
|
||||
'secret': UPLOAD_SERVICE_SECRET,
|
||||
'user': r.user.id,
|
||||
'boattype': '1x',
|
||||
'workouttype': workouttype,
|
||||
@@ -555,30 +565,25 @@ class IntervalsIntegration(SyncIntegration):
|
||||
'offline': False,
|
||||
}
|
||||
|
||||
url = UPLOAD_SERVICE_URL
|
||||
handle_request_post(url, uploadoptions)
|
||||
response = upload_handler(uploadoptions, fit_filename)
|
||||
|
||||
try:
|
||||
pair_id = data['paired_event_id']
|
||||
pss = PlannedSession.objects.filter(intervals_icu_id=pair_id, rower=r)
|
||||
ws = Workout.objects.filter(uploadedtointervals=id)
|
||||
for w in ws:
|
||||
w.sub_type = subtype
|
||||
w.save()
|
||||
|
||||
w.sub_type = subtype
|
||||
w.save()
|
||||
if is_commute:
|
||||
for w in ws:
|
||||
w.is_commute = True
|
||||
w.sub_type = "Commute"
|
||||
w.save()
|
||||
w.is_commute = True
|
||||
w.sub_type = "Commute"
|
||||
w.save()
|
||||
if is_race:
|
||||
for w in ws:
|
||||
w.is_race = True
|
||||
w.save()
|
||||
w.is_race = True
|
||||
w.save()
|
||||
if pss.count() > 0:
|
||||
for ps in pss:
|
||||
for w in ws:
|
||||
w.plannedsession = ps
|
||||
w.save()
|
||||
w.plannedsession = ps
|
||||
w.save()
|
||||
except KeyError:
|
||||
pass
|
||||
except PlannedSession.DoesNotExist:
|
||||
|
||||
@@ -103,6 +103,8 @@ class PolarIntegration(SyncIntegration):
|
||||
return 1
|
||||
|
||||
def get_polar_workouts(self, user):
|
||||
from rowers.dataflow import upload_handler
|
||||
|
||||
r = Rower.objects.get(user=user)
|
||||
|
||||
exercise_list = []
|
||||
@@ -191,28 +193,9 @@ class PolarIntegration(SyncIntegration):
|
||||
'title': '',
|
||||
}
|
||||
|
||||
url = settings.UPLOAD_SERVICE_URL
|
||||
|
||||
dologging('polar.log', uploadoptions)
|
||||
dologging('polar.log', url)
|
||||
|
||||
_ = myqueue(
|
||||
queuehigh,
|
||||
handle_request_post,
|
||||
url,
|
||||
uploadoptions
|
||||
)
|
||||
|
||||
dologging('polar.log', response.status_code)
|
||||
if response.status_code != 200: # pragma: no cover
|
||||
try:
|
||||
dologging('polar.log', response.text)
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
dologging('polar.log', response.json())
|
||||
except:
|
||||
pass
|
||||
response = upload_handler(uploadoptions, filename)
|
||||
if response['status'] != 'processing':
|
||||
return 0
|
||||
|
||||
exercise_dict['filename'] = filename
|
||||
else: # pragma: no cover
|
||||
|
||||
@@ -4,7 +4,6 @@ from rowers.models import User, Rower, Workout, TombStone
|
||||
from rowers.upload_tasks import handle_rp3_async_workout
|
||||
from rowsandall_app.settings import (
|
||||
RP3_CLIENT_ID, RP3_CLIENT_KEY, RP3_REDIRECT_URI, RP3_CLIENT_SECRET,
|
||||
UPLOAD_SERVICE_URL, UPLOAD_SERVICE_SECRET
|
||||
)
|
||||
|
||||
from rowers.utils import myqueue, NoTokenError, dologging, uniqify
|
||||
|
||||
Reference in New Issue
Block a user