blockers through the db
This commit is contained in:
63
rowers/management/commands/getsyncids.py
Normal file
63
rowers/management/commands/getsyncids.py
Normal file
@@ -0,0 +1,63 @@
|
||||
from django.core.management.base import BaseCommand
|
||||
from rowers.models import Workout, TombStone, SyncRecord
|
||||
from django.utils import timezone
|
||||
from django.db.utils import IntegrityError
|
||||
|
||||
class Command(BaseCommand):
|
||||
def handle(self, *args, **options):
|
||||
ws = Workout.objects.all()
|
||||
aantal = ws.count()
|
||||
counter = 0
|
||||
print('----- Workouts ---------')
|
||||
for w in ws:
|
||||
record = SyncRecord(
|
||||
workout = w,
|
||||
)
|
||||
if w.uploadedtostrava:
|
||||
record.stravaid = w.uploadedtostrava
|
||||
if w.uploadedtotp:
|
||||
record.tpid = w.uploadedtotp
|
||||
if w.uploadedtonk:
|
||||
record.nkid = w.uploadedtonk
|
||||
if w.uploadedtosporttracks:
|
||||
record.sporttracksid = w.uploadedtosporttracks
|
||||
if w.uploadedtoc2:
|
||||
record.c2id = w.uploadedtoc2
|
||||
|
||||
try:
|
||||
record.save()
|
||||
except IntegrityError:
|
||||
pass
|
||||
|
||||
counter += 1
|
||||
if counter % 10 == 0:
|
||||
print(counter,'/',aantal)
|
||||
|
||||
print('----- Tombstones -------')
|
||||
ts = TombStone.objects.all()
|
||||
aantal = ts.count()
|
||||
counter = 0
|
||||
for w in ts:
|
||||
record = SyncRecord(
|
||||
)
|
||||
if w.uploadedtostrava:
|
||||
record.stravaid = w.uploadedtostrava
|
||||
if w.uploadedtotp:
|
||||
record.tpid = w.uploadedtotp
|
||||
if w.uploadedtonk:
|
||||
record.nkid = w.uploadedtonk
|
||||
if w.uploadedtosporttracks:
|
||||
record.sporttracksid = w.uploadedtosporttracks
|
||||
if w.uploadedtoc2:
|
||||
record.c2id = w.uploadedtoc2
|
||||
|
||||
try:
|
||||
record.save()
|
||||
except IntegrityError:
|
||||
pass
|
||||
|
||||
counter += 1
|
||||
if counter % 10 == 0:
|
||||
print(counter,'/',aantal)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user