Private
Public Access
1
0

removed UnderArmour / MapMyFitness

This commit is contained in:
Sander Roosendaal
2021-05-21 09:36:38 +02:00
parent 3d208527ee
commit b58ba932fd
22 changed files with 54 additions and 1527 deletions

View File

@@ -25,6 +25,8 @@ from rowingdata import rowingdata as rdata
from datetime import timedelta
from sqlalchemy import create_engine
from rowers.imports import splituadata
#from celery import app
from rowers.celery import app
from celery import shared_task
@@ -64,7 +66,7 @@ from django_rq import job
from django.utils import timezone
from django.utils.html import strip_tags
from rowers.utils import deserialize_list,ewmovingaverage,wavg
from rowers.utils import deserialize_list,ewmovingaverage,wavg,dologging
from rowers.emails import htmlstrip
from rowers import mytypes
@@ -125,15 +127,6 @@ from rowers.courseutils import (
InvalidTrajectoryError
)
def dologging(s):
tstamp = time.localtime()
timestamp = time.strftime('%b-%d-%Y %H:%M:%S', tstamp)
with open('debuglog.log','a') as f:
f.write('\n')
f.write(timestamp)
f.write(' ')
f.write(s)
# Concept2 logbook sends over split data for each interval
# We use it here to generate a custom summary
# Some users complained about small differences
@@ -2985,7 +2978,23 @@ def handle_nk_async_workout(alldata,userid,nktoken,nkid,delaysec,defaulttimezone
# return
return workoutid
@app.task
def handle_c2_getworkout(userid,c2token,c2id,defaulttimezone,debug=False,**kwargs):
authorizationstring = str('Bearer ' + c2token)
headers = {'Authorization': authorizationstring,
'user-agent': 'sanderroosendaal',
'Content-Type': 'application/json'}
url = "https://log.concept2.com/api/users/me/results/"+str(c2id)
s = requests.get(url,headers=headers)
if s.status_code != 200: # pragma: no cover
return 0
data = s.json()['data']
alldata = {c2id:data}
splitdata = None
return handle_c2_async_workout(alldata,userid,c2token,c2id,0,defaulttimezone)
@app.task
def handle_c2_async_workout(alldata,userid,c2token,c2id,delaysec,defaulttimezone,debug=False,**kwargs):
@@ -3007,8 +3016,8 @@ def handle_c2_async_workout(alldata,userid,c2token,c2id,delaysec,defaulttimezone
weightclass = data['weight_class']
s = 'User {userid}, C2 ID {c2id}'.format(userid=userid,c2id=c2id)
dologging(s)
dologging(json.dumps(data))
dologging('debuglog.log',s)
dologging('debuglog.log',json.dumps(data))
try:
title = data['name']
@@ -3041,7 +3050,7 @@ def handle_c2_async_workout(alldata,userid,c2token,c2id,delaysec,defaulttimezone
s = 'Time zone {timezone}, stardatetime {startdatetime}, duration {duration}'.format(
timezone=timezone,startdatetime=startdatetime,
duration=duration)
dologging(s)
dologging('debuglog.log',s)
@@ -3246,6 +3255,7 @@ def handle_c2_async_workout(alldata,userid,c2token,c2id,delaysec,defaulttimezone
return workoutid
@app.task
def fetch_strava_workout(stravatoken,oauth_data,stravaid,csvfilename,userid,debug=False,**kwargs):
fetchresolution = 'high'