fixing c2 import
This commit is contained in:
@@ -183,10 +183,26 @@ def get_c2_workouts(rower,do_async=True):
|
||||
t.uploadedtoc2 for t in TombStone.objects.filter(user=rower)
|
||||
]
|
||||
|
||||
knownc2ids = uniqify(knownc2ids+tombstones)
|
||||
# get "blocked" c2ids
|
||||
parkedids = []
|
||||
try:
|
||||
with open('c2blocked.json','r') as c2blocked:
|
||||
jsondata = json.load(c2blocked)
|
||||
parkedids = jsondata['ids']
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
|
||||
|
||||
knownc2ids = uniqify(knownc2ids+tombstones+parkedids)
|
||||
|
||||
newids = [c2id for c2id in c2ids if not c2id in knownc2ids]
|
||||
|
||||
newparkedids = uniqify(newids+parkedids)
|
||||
|
||||
with open('c2blocked.json','wt') as c2blocked:
|
||||
data = {'ids':newparkedids}
|
||||
json.dump(data,c2blocked)
|
||||
|
||||
for c2id in newids:
|
||||
if do_async:
|
||||
res = myqueue(queuehigh,
|
||||
@@ -372,6 +388,20 @@ def create_async_workout(alldata,user,c2id):
|
||||
except KeyError:
|
||||
workoutid = 1
|
||||
|
||||
newc2id = Workout.objects.get(id=workoutid).uploadedtoc2
|
||||
|
||||
parkedids = []
|
||||
with open('c2blocked.json','r') as c2blocked:
|
||||
jsondata = json.load(c2blocked)
|
||||
parkedids = jsondata['ids']
|
||||
|
||||
newparkedids = [id for id in parkedids if id != newc2id]
|
||||
with open('c2blocked.json','wt') as c2blocked:
|
||||
data = {'ids':newparkedids}
|
||||
c2blocked.seek(0)
|
||||
json.dump(data,c2blocked)
|
||||
|
||||
|
||||
return workoutid
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user