configuration of Physics calc to report progress
Needs rowingdata >= 1.3.2
This commit is contained in:
@@ -347,7 +347,7 @@ def handle_sendemailcsv(first_name, last_name, email, csvfile,debug=False):
|
||||
|
||||
|
||||
@app.task(bind=True)
|
||||
def handle_otwsetpower(f1, boattype, weightvalue,
|
||||
def handle_otwsetpower(self,f1, boattype, weightvalue,
|
||||
first_name, last_name, email, workoutid,
|
||||
**kwargs):
|
||||
# ps=[
|
||||
@@ -359,6 +359,19 @@ def handle_otwsetpower(f1, boattype, weightvalue,
|
||||
|
||||
if 'jobkey' in kwargs:
|
||||
job_id = kwargs.pop('jobkey')
|
||||
if 'ps' in kwargs:
|
||||
ps = kwargs['ps']
|
||||
else:
|
||||
ps = [1,1,1,1]
|
||||
|
||||
if 'ratio' in kwargs:
|
||||
ratio = kwargs['ratio']
|
||||
else:
|
||||
ratio = 1.0
|
||||
if 'debug' in kwargs:
|
||||
debug = kwargs['debug']
|
||||
else:
|
||||
debug = False
|
||||
|
||||
kwargs['jobid'] = job_id
|
||||
|
||||
@@ -402,7 +415,7 @@ def handle_otwsetpower(f1, boattype, weightvalue,
|
||||
secret = PROGRESS_CACHE_SECRET
|
||||
|
||||
progressurl += "/rowers/record-progress/"
|
||||
progressurl += str(progress)+"/"+jobid
|
||||
progressurl += job_id
|
||||
|
||||
rowdata.otw_setpower_silent(skiprows=5, mc=weightvalue, rg=rg,
|
||||
powermeasured=powermeasured,
|
||||
|
||||
@@ -144,6 +144,8 @@ urlpatterns = [
|
||||
url(r'^test-job/(?P<aantal>\d+)$',views.test_job_view),
|
||||
url(r'^test-job2/(?P<aantal>\d+)$',views.test_job_view2),
|
||||
url(r'^record-progress/(?P<value>\d+)/(?P<id>.*)$',views.post_progress),
|
||||
url(r'^record-progress/(?P<id>.*)$',views.post_progress),
|
||||
url(r'^record-progress$',views.post_progress),
|
||||
url(r'^list-graphs/$',views.graphs_view),
|
||||
url(r'^(?P<theuser>\d+)/ote-bests/(?P<startdatestring>\w+.*)/(?P<enddatestring>\w+.*)$',views.rankings_view),
|
||||
url(r'^(?P<theuser>\d+)/ote-bests/(?P<deltadays>\d+)$',views.rankings_view),
|
||||
|
||||
@@ -222,11 +222,17 @@ def isbreakthrough(delta,cpvalues,p0,p1,p2,p3,ratio):
|
||||
def myqueue(queue,function,*args,**kwargs):
|
||||
if settings.DEBUG:
|
||||
kwargs['debug'] = True
|
||||
|
||||
print 'myqueue'
|
||||
print args
|
||||
print kwargs
|
||||
|
||||
job = function.delay(*args,**kwargs)
|
||||
else:
|
||||
job_id = str(uuid.uuid4())
|
||||
kwargs['job_id'] = job_id
|
||||
kwargs['jobkey'] = job_id
|
||||
|
||||
job = queue.enqueue(function,*args,**kwargs)
|
||||
|
||||
return job
|
||||
|
||||
@@ -367,19 +367,32 @@ def test_job_view2(request,aantal=100):
|
||||
@csrf_exempt
|
||||
def post_progress(request,id=None,value=0):
|
||||
if request.method == 'POST':
|
||||
secret = request.POST['secret']
|
||||
try:
|
||||
secret = request.POST['secret']
|
||||
except KeyError:
|
||||
return HttpResponse('Access Denied',status=401)
|
||||
if secret == settings.PROGRESS_CACHE_SECRET:
|
||||
if id:
|
||||
cache.set(id,value,3600)
|
||||
# test
|
||||
result = cache.get(id)
|
||||
if not id:
|
||||
try:
|
||||
id = request.POST['id']
|
||||
except KeyError:
|
||||
return HttpResponse('Invalid request',400)
|
||||
try:
|
||||
value = request.POST['value']
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
return HttpResponse('progress cached '+str(result),status=200)
|
||||
else:
|
||||
return HttpResponse('access denied',status=400)
|
||||
cache.set(id,value,3600)
|
||||
# test
|
||||
result = cache.get(id)
|
||||
|
||||
else:
|
||||
return HttpResponse('hi',status=200)
|
||||
return HttpResponse('progress cached '+str(result),
|
||||
status=201)
|
||||
else: # secret not given
|
||||
return HttpResponse('access denied',status=401)
|
||||
|
||||
else: # request method is not POST
|
||||
return HttpResponse('GET method not allowed',status=405)
|
||||
|
||||
def get_all_queued_jobs(userid=0):
|
||||
r = StrictRedis()
|
||||
|
||||
Reference in New Issue
Block a user