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.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
import os

View File

@@ -88,6 +88,8 @@ def get_strava_workouts(rower):
res = get_strava_workout_list(rower.user,limit_n=10)
print res.status_code
if (res.status_code != 200):
return 0
else:
@@ -121,7 +123,6 @@ def get_strava_workouts(rower):
newids = [stravaid for stravaid in stravaids if not stravaid in knownstravaids]
for stravaid in newids:
result = create_async_workout(alldata,rower.user,stravaid)
@@ -137,6 +138,11 @@ def create_async_workout(alldata,user,stravaid,debug=False):
except:
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]:
workouttype = 'other'
@@ -205,6 +211,7 @@ def create_async_workout(alldata,user,stravaid,debug=False):
stravaid,
starttimeunix,
csvfilename,
workouttype = workouttype,
)
return 1
@@ -402,6 +409,11 @@ def add_workout_from_data(user,importid,data,strokedata,
workouttype = data['type']
except KeyError:
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]:
workouttype = 'other'
@@ -593,7 +605,9 @@ def handle_strava_import_stroke_data(title,
stravatoken,
stravaid,
starttimeunix,
csvfilename,debug=True,**kwargs):
csvfilename,debug=True,
workouttype = 'rower',
**kwargs):
# ready to fetch. Hurray
fetchresolution = 'high'
@@ -717,7 +731,11 @@ def handle_strava_import_stroke_data(title,
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,
from_header=useremail,

View File

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

View File

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