quiske fixes
This commit is contained in:
@@ -110,6 +110,12 @@ from django.core.exceptions import ValidationError
|
||||
from time import strftime
|
||||
import arrow
|
||||
|
||||
from rq.job import Job
|
||||
from rq.registry import StartedJobRegistry
|
||||
from redis import Redis
|
||||
from rq import Queue
|
||||
|
||||
|
||||
thetimezone = get_current_timezone()
|
||||
|
||||
allowedcolumns = [key for key, value in strokedatafields.items()]
|
||||
@@ -1542,7 +1548,24 @@ def new_workout_from_df(r, df,
|
||||
# A wrapper around the rowingdata class, with some error catching
|
||||
|
||||
|
||||
from redis import StrictRedis, Redis
|
||||
|
||||
def get_existing_job(w):
|
||||
# check if this filename is in the queue
|
||||
r = StrictRedis()
|
||||
for key in r.keys():
|
||||
res = key.decode('utf8').split(':')
|
||||
if len(res) == 3:
|
||||
jobid = res[2]
|
||||
try:
|
||||
job = Job.fetch(jobid, connection=r)
|
||||
if isinstance(job.args[1], str):
|
||||
if job.args[1] == w.csvfilename:
|
||||
return 1
|
||||
except:
|
||||
pass
|
||||
|
||||
return 0
|
||||
|
||||
def workout_trimp(w, reset=False):
|
||||
r = w.user
|
||||
@@ -1550,6 +1573,9 @@ def workout_trimp(w, reset=False):
|
||||
if w.trimp > 0 and not reset:
|
||||
return w.trimp, w.hrtss
|
||||
|
||||
if get_existing_job(w):
|
||||
return 0, 0
|
||||
|
||||
r = w.user
|
||||
ftp = float(r.ftp)
|
||||
if w.workouttype in otwtypes:
|
||||
@@ -1592,6 +1618,9 @@ def workout_rscore(w, reset=False):
|
||||
if w.rscore > 0 and not reset:
|
||||
return w.rscore, w.normp
|
||||
|
||||
if get_existing_job(w):
|
||||
return 0, 0
|
||||
|
||||
r = w.user
|
||||
ftp = float(r.ftp)
|
||||
if w.workouttype in otwtypes:
|
||||
@@ -1620,6 +1649,9 @@ def workout_normv(w, pp=4.0):
|
||||
if w.normv > 0: # pragma: no cover
|
||||
return w.normv, w.normw
|
||||
|
||||
if get_existing_job(w):
|
||||
return 0, 0
|
||||
|
||||
r = w.user
|
||||
ftp = float(r.ftp)
|
||||
if w.workouttype in otwtypes:
|
||||
|
||||
Reference in New Issue
Block a user