Private
Public Access
1
0

adding start date to tasks

This commit is contained in:
Sander Roosendaal
2018-07-12 21:34:35 +02:00
parent d19cbb34d4
commit 0e70a43a4e
4 changed files with 35 additions and 6 deletions

View File

@@ -40,8 +40,10 @@ from rowingdata import (
) )
from rowers.metrics import axes,calc_trimp,rowingmetrics from rowers.metrics import axes,calc_trimp,rowingmetrics
from rowers.models import strokedatafields
allowedcolumns = [item[0] for item in rowingmetrics] #allowedcolumns = [item[0] for item in rowingmetrics]
allowedcolumns = [key for key,value in strokedatafields.items()]
from async_messages import messages as a_messages from async_messages import messages as a_messages
import os import os

View File

@@ -88,6 +88,8 @@ def get_strava_workouts(rower):
res = get_strava_workout_list(rower.user,limit_n=10) res = get_strava_workout_list(rower.user,limit_n=10)
print res.status_code
if (res.status_code != 200): if (res.status_code != 200):
return 0 return 0
else: else:
@@ -121,7 +123,6 @@ def get_strava_workouts(rower):
newids = [stravaid for stravaid in stravaids if not stravaid in knownstravaids] newids = [stravaid for stravaid in stravaids if not stravaid in knownstravaids]
for stravaid in newids: for stravaid in newids:
result = create_async_workout(alldata,rower.user,stravaid) result = create_async_workout(alldata,rower.user,stravaid)
@@ -137,6 +138,11 @@ def create_async_workout(alldata,user,stravaid,debug=False):
except: except:
workouttype = 'rower' workouttype = 'rower'
if workouttype.lower() == 'rowing':
workouttype = 'rower'
if 'summary_polyline' in data['map']:
workouttype = 'water'
if workouttype not in [x[0] for x in Workout.workouttypes]: if workouttype not in [x[0] for x in Workout.workouttypes]:
workouttype = 'other' workouttype = 'other'
@@ -205,6 +211,7 @@ def create_async_workout(alldata,user,stravaid,debug=False):
stravaid, stravaid,
starttimeunix, starttimeunix,
csvfilename, csvfilename,
workouttype = workouttype,
) )
return 1 return 1
@@ -402,6 +409,11 @@ def add_workout_from_data(user,importid,data,strokedata,
workouttype = data['type'] workouttype = data['type']
except KeyError: except KeyError:
workouttype = 'rower' workouttype = 'rower'
if workouttype.lower() == 'rowing':
workouttype = 'rower'
if 'summary_polyline' in data['map']:
workouttype = 'water'
if workouttype not in [x[0] for x in Workout.workouttypes]: if workouttype not in [x[0] for x in Workout.workouttypes]:
workouttype = 'other' workouttype = 'other'
@@ -593,7 +605,9 @@ def handle_strava_import_stroke_data(title,
stravatoken, stravatoken,
stravaid, stravaid,
starttimeunix, starttimeunix,
csvfilename,debug=True,**kwargs): csvfilename,debug=True,
workouttype = 'rower',
**kwargs):
# ready to fetch. Hurray # ready to fetch. Hurray
fetchresolution = 'high' fetchresolution = 'high'
@@ -717,7 +731,11 @@ def handle_strava_import_stroke_data(title,
workoutsbox = Mailbox.objects.filter(name='workouts')[0] workoutsbox = Mailbox.objects.filter(name='workouts')[0]
body = 'stravaid {stravaid}'.format(stravaid=stravaid) body = """stravaid {stravaid}
workouttype {workouttype}""".format(
stravaid=stravaid,
workouttype=workouttype
)
msg = Message(mailbox=workoutsbox, msg = Message(mailbox=workoutsbox,
from_header=useremail, from_header=useremail,

View File

@@ -69,6 +69,7 @@
<tr> <tr>
<th>ID</th> <th>ID</th>
<th>Task</th> <th>Task</th>
<th>Started</th>
<th>Progress</th> <th>Progress</th>
<th>Status</th> <th>Status</th>
<th>Action</th> <th>Action</th>
@@ -84,6 +85,9 @@
{{ task|lookup:'verbose' }} {{ task|lookup:'verbose' }}
</td> </td>
<td> <td>
{{ task|lookup:'started_at' }}
</td>
<td>
<div class="progressBar" data="max{{ task|lookup:'progress' }}" style="width: 100%;"> <div class="progressBar" data="max{{ task|lookup:'progress' }}" style="width: 100%;">
<div data-show=""> {{ task|lookup:'progress' }}</div> <div data-show=""> {{ task|lookup:'progress' }}</div>
</div> </div>

View File

@@ -386,12 +386,14 @@ def get_job_status(jobid):
if settings.DEBUG: if settings.DEBUG:
job = celery_result.AsyncResult(jobid) job = celery_result.AsyncResult(jobid)
jobresult = job.result jobresult = job.result
if 'fail' in job.status.lower(): if 'fail' in job.status.lower():
jobresult = '0' jobresult = '0'
summary = { summary = {
'status': job.status, 'status': job.status,
'result': jobresult, 'result': jobresult,
'started_at': None
} }
else: else:
try: try:
@@ -399,11 +401,13 @@ def get_job_status(jobid):
summary = { summary = {
'status':job.status, 'status':job.status,
'result':job.result, 'result':job.result,
'started_at':job.started_at
} }
except NoSuchJobError: except NoSuchJobError:
summary = { summary = {
'status': 'success', 'status': 'success',
'result': 1, 'result': 1,
'started_at':None,
} }
try: try:
@@ -423,7 +427,8 @@ def get_job_status(jobid):
'status': 'failed', 'status': 'failed',
'result': 0, 'result': 0,
'finished': True, 'finished': True,
'failed': True 'failed': True,
'started_at':None,
} }
return summary return summary
@@ -9212,7 +9217,7 @@ def workout_stravaimport_view(request,message=""):
w.uploadedtostrava for w in Workout.objects.filter(user=r) w.uploadedtostrava for w in Workout.objects.filter(user=r)
]) ])
newids = [stravaid for stravaid in stravaids if not stravaid in knownstravaids] newids = [stravaid for stravaid in stravaids if not stravaid in knownstravaids]
for item in res.json(): for item in res.json():
d = int(float(item['distance'])) d = int(float(item['distance']))
i = item['id'] i = item['id']