improving syncrecord functionality, now also for workout export
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
from .integrations import SyncIntegration, NoTokenError
|
||||
from rowers.models import User, Rower, Workout, TombStone, SyncRecord
|
||||
from .integrations import SyncIntegration, NoTokenError, create_or_update_syncrecord, get_known_ids
|
||||
from rowers.models import User, Rower, Workout, TombStone
|
||||
from django.db.utils import IntegrityError
|
||||
|
||||
from rowingdata import rowingdata
|
||||
@@ -360,15 +360,9 @@ class C2Integration(SyncIntegration):
|
||||
|
||||
def get_workout(self, id, *args, **kwargs):
|
||||
_ = self.open()
|
||||
r = self.rower
|
||||
|
||||
record = SyncRecord(
|
||||
rower = self.rower,
|
||||
c2id = id,
|
||||
)
|
||||
try:
|
||||
record.save()
|
||||
except IntegrityError:
|
||||
return 0
|
||||
record = create_or_update_syncrecord(r, None, c2id=id)
|
||||
|
||||
_ = myqueue(queuehigh,
|
||||
handle_c2_getworkout,
|
||||
@@ -428,9 +422,7 @@ class C2Integration(SyncIntegration):
|
||||
workouts = []
|
||||
c2ids = [item['id'] for item in res.json()['data']]
|
||||
|
||||
knownc2ids = uniqify([
|
||||
record.c2id for record in SyncRecord.objects.filter(rower=r)
|
||||
])
|
||||
knownc2ids = get_known_ids(r, 'c2id')
|
||||
|
||||
for item in res.json()['data']:
|
||||
d = item['distance']
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from abc import ABCMeta, ABC, abstractmethod
|
||||
from importlib import import_module
|
||||
from rowers.models import Rower, User, create_or_update_syncrecord
|
||||
from rowers.models import Rower, User, create_or_update_syncrecord, get_known_ids
|
||||
from rowers.utils import NoTokenError,dologging
|
||||
|
||||
import requests
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from .integrations import SyncIntegration, NoTokenError, create_or_update_syncrecord
|
||||
from rowers.models import User, Rower, Workout, TombStone, SyncRecord
|
||||
from .integrations import SyncIntegration, NoTokenError, create_or_update_syncrecord, get_known_ids
|
||||
from rowers.models import User, Rower, Workout, TombStone
|
||||
from django.db.utils import IntegrityError
|
||||
|
||||
from rowers import mytypes
|
||||
@@ -185,9 +185,7 @@ class NKIntegration(SyncIntegration):
|
||||
|
||||
# get NK IDs
|
||||
nkids = [item['id'] for item in jsondata]
|
||||
knownnkids = uniqify([
|
||||
record.nkid for record in SyncRecord.objects.filter(rower=r)
|
||||
])
|
||||
knownnkids = get_known_ids(r, 'nkid')
|
||||
workouts = []
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user