Merge branch 'feature/autoc2import' into develop
This commit is contained in:
BIN
logos/ritmo_logo.gif
Normal file
BIN
logos/ritmo_logo.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 8.6 KiB |
@@ -34,7 +34,7 @@ import sys
|
||||
import urllib
|
||||
from requests import Request, Session
|
||||
|
||||
from utils import myqueue
|
||||
from utils import myqueue,uniqify,isprorower
|
||||
|
||||
from rowers.types import otwtypes
|
||||
|
||||
@@ -114,7 +114,37 @@ def add_stroke_data(user,c2id,workoutid,startdatetime,csvfilename):
|
||||
csvfilename)
|
||||
|
||||
return 1
|
||||
|
||||
def get_c2_workouts(rower):
|
||||
|
||||
if not isprorower(rower):
|
||||
return 0
|
||||
|
||||
try:
|
||||
thetoken = c2_open(rower.user)
|
||||
except C2NoTokenError:
|
||||
return 0
|
||||
|
||||
res = get_c2_workout_list(rower.user,page=1)
|
||||
|
||||
if (res.status_code != 200):
|
||||
return 0
|
||||
else:
|
||||
c2ids = [item['id'] for item in res.json()['data']]
|
||||
alldata = {}
|
||||
for item in res.json()['data']:
|
||||
alldata[item['id']] = item
|
||||
|
||||
knownc2ids = uniqify([
|
||||
w.uploadedtoc2 for w in Workout.objects.filter(user=rower)
|
||||
])
|
||||
newids = [c2id for c2id in c2ids if not c2id in knownc2ids]
|
||||
|
||||
for c2id in newids:
|
||||
workoutid = create_async_workout(alldata,
|
||||
rower.user,c2id)
|
||||
|
||||
return 1
|
||||
|
||||
# get workout metrics, then relay stroke data to an asynchronous task
|
||||
def create_async_workout(alldata,user,c2id):
|
||||
@@ -155,7 +185,7 @@ def create_async_workout(alldata,user,c2id):
|
||||
w = Workout(
|
||||
user=r,
|
||||
workouttype = workouttype,
|
||||
name = 'Imported workout',
|
||||
name = 'C2 Import Workout from {startdatetime}'.format(startdatetime=startdatetime),
|
||||
date = workoutdate,
|
||||
starttime = starttime,
|
||||
startdatetime = startdatetime,
|
||||
|
||||
@@ -1999,7 +1999,11 @@ def dataprep(rowdatadf, id=0, bands=True, barchart=True, otwpower=True,
|
||||
rowdatadf.loc[row_index, ' Stroke500mPace (sec/500m)'] = 3000.
|
||||
|
||||
p = rowdatadf.ix[:, ' Stroke500mPace (sec/500m)']
|
||||
velo = rowdatadf.ix[:,' AverageBoatSpeed (m/s)']
|
||||
try:
|
||||
velo = rowdatadf.ix[:,' AverageBoatSpeed (m/s)']
|
||||
except KeyError:
|
||||
velo = 500./p
|
||||
|
||||
hr = rowdatadf.ix[:, ' HRCur (bpm)']
|
||||
spm = rowdatadf.ix[:, ' Cadence (stokes/min)']
|
||||
cumdist = rowdatadf.ix[:, 'cum_dist']
|
||||
|
||||
@@ -978,7 +978,11 @@ def dataprep(rowdatadf,id=0,bands=True,barchart=True,otwpower=True,
|
||||
rowdatadf.loc[row_index,' Stroke500mPace (sec/500m)'] = 3000.
|
||||
|
||||
p = rowdatadf.ix[:,' Stroke500mPace (sec/500m)']
|
||||
velo = rowdatadf.ix[:,' AverageBoatSpeed (m/s)']
|
||||
try:
|
||||
velo = rowdatadf.ix[:,' AverageBoatSpeed (m/s)']
|
||||
except KeyError:
|
||||
velo = 500./p
|
||||
|
||||
hr = rowdatadf.ix[:,' HRCur (bpm)']
|
||||
spm = rowdatadf.ix[:,' Cadence (stokes/min)']
|
||||
cumdist = rowdatadf.ix[:,'cum_dist']
|
||||
|
||||
@@ -168,7 +168,7 @@ def make_new_workout_from_email(rower, datafile, name, cntr=0,testing=False):
|
||||
oarlength=oarlength,
|
||||
title=name,
|
||||
workoutsource=fileformat,
|
||||
notes='imported through email'
|
||||
notes=''
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ from rowingdata import rowingdata as rrdata
|
||||
import rowers.uploads as uploads
|
||||
from rowers.mailprocessing import make_new_workout_from_email, send_confirm
|
||||
import rowers.polarstuff as polarstuff
|
||||
import rowers.c2stuff as c2stuff
|
||||
|
||||
workoutmailbox = Mailbox.objects.get(name='workouts')
|
||||
failedmailbox = Mailbox.objects.get(name='Failed')
|
||||
@@ -148,8 +149,14 @@ class Command(BaseCommand):
|
||||
|
||||
"""Run the Email processing command """
|
||||
def handle(self, *args, **options):
|
||||
# Polar
|
||||
polar_available = polarstuff.get_polar_notifications()
|
||||
res = polarstuff.get_all_new_workouts(polar_available)
|
||||
|
||||
# Concept2
|
||||
rowers = Rower.objects.filter(c2_auto_import=True)
|
||||
for r in rowers:
|
||||
c2stuff.get_c2_workouts(r)
|
||||
|
||||
messages = Message.objects.filter(mailbox_id = workoutmailbox.id)
|
||||
message_ids = [m.id for m in messages]
|
||||
|
||||
@@ -643,6 +643,7 @@ class Rower(models.Model):
|
||||
tokenexpirydate = models.DateTimeField(blank=True,null=True)
|
||||
c2refreshtoken = models.CharField(default='',max_length=200,blank=True,null=True)
|
||||
c2_auto_export = models.BooleanField(default=False)
|
||||
c2_auto_import = models.BooleanField(default=False)
|
||||
sporttrackstoken = models.CharField(default='',max_length=200,blank=True,null=True)
|
||||
sporttrackstokenexpirydate = models.DateTimeField(blank=True,null=True)
|
||||
sporttracksrefreshtoken = models.CharField(default='',max_length=200,
|
||||
@@ -2020,6 +2021,7 @@ class RowerImportExportForm(ModelForm):
|
||||
fields = [
|
||||
'polar_auto_import',
|
||||
'c2_auto_export',
|
||||
'c2_auto_import',
|
||||
'mapmyfitness_auto_export',
|
||||
'runkeeper_auto_export',
|
||||
'sporttracks_auto_export',
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
<li> BoatCoach </li>
|
||||
<li> RowingCoach </li>
|
||||
<li> Quiske RowP</li>
|
||||
<li> Ritmo Time</li>
|
||||
<li> Speedcoach XL (CSV)</li>
|
||||
<li> Speedcoach GPS (FIT and CSV)</li></ul></p>
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
<img src="/static/img/bcsquare.png" alt="BoatCoach icon" width="30" height="30">
|
||||
<img src="/static/img/pssquare.png" alt="PainSled icon" width="30" height="30">
|
||||
<img src="/static/img/coxmate.png" alt="CoxMate icon" width="30" height="30">
|
||||
<img src="/static/img/ritmo_logo.gif" alt="RitmoTime icon" width="30" height="30">
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
||||
BIN
static/img/ritmo_logo.gif
Normal file
BIN
static/img/ritmo_logo.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 8.6 KiB |
Reference in New Issue
Block a user