refactor, stage 1
This commit is contained in:
@@ -15,7 +15,7 @@ application = get_wsgi_application()
|
||||
from rowers.models import (
|
||||
Workout, GeoPolygon, GeoPoint, GeoCourse,
|
||||
VirtualRaceResult, CourseTestResult, Rower,
|
||||
GraphImage, SyncRecord
|
||||
GraphImage
|
||||
)
|
||||
|
||||
import math
|
||||
@@ -35,6 +35,7 @@ import arrow
|
||||
import rowers.longtask as longtask
|
||||
import requests
|
||||
import rowers.datautils as datautils
|
||||
from rowers.models import create_or_update_syncrecord
|
||||
|
||||
""" Background tasks done by QR (production) """
|
||||
import time
|
||||
@@ -523,8 +524,8 @@ def handle_c2_sync(workoutid, url, headers, data, debug=False, **kwargs):
|
||||
workout.uploadedtoc2 = c2id
|
||||
workout.save()
|
||||
|
||||
record = SyncRecord(workout=workout,c2id=c2id)
|
||||
record.save()
|
||||
record = create_or_update_syncrecord(workout.user, workout, c2id=c2id)
|
||||
|
||||
|
||||
return 1
|
||||
|
||||
@@ -3409,19 +3410,7 @@ def handle_nk_async_workout(alldata, userid, nktoken, nkid, delaysec, defaulttim
|
||||
|
||||
workout = Workout.objects.get(id=workoutid)
|
||||
newnkid = workout.uploadedtonk
|
||||
sr = SyncRecord.objects.filter(nkid=newnkid)
|
||||
if len(sr):
|
||||
sr[0].workout = workout
|
||||
try:
|
||||
sr[0].save()
|
||||
except IntegrityError:
|
||||
pass
|
||||
else:
|
||||
sr = SyncRecord(workout=workout,nkid=newnkid)
|
||||
try:
|
||||
sr.save()
|
||||
except IntegrityError:
|
||||
pass
|
||||
sr = create_or_update_syncrecord(workout.user, workout, nkid=newnkid)
|
||||
|
||||
return workoutid
|
||||
|
||||
@@ -3696,7 +3685,7 @@ def handle_c2_async_workout(alldata, userid, c2token, c2id, delaysec,
|
||||
workout = Workout.objects.get(id=workoutid)
|
||||
newc2id = workout.uploadedtoc2
|
||||
|
||||
record = SyncRecord(workout=workout,c2id=newc2id)
|
||||
record = create_or_update_syncrecord(workout.user, workout, c2id=newc2id)
|
||||
|
||||
|
||||
# set distance, time
|
||||
|
||||
Reference in New Issue
Block a user