Persist best efforts during import and add resumable backfill
This commit is contained in:
@@ -8,6 +8,7 @@ from garmin_sync.service import SyncError, complete, decode_fit
|
||||
|
||||
from .extensions import db
|
||||
from .models import Activity
|
||||
from .records import persist_efforts
|
||||
|
||||
|
||||
def number(value, default=0):
|
||||
@@ -110,6 +111,7 @@ def activity_from_fit(owner_id, source_key, documents, metadata=None, refresh=Fa
|
||||
}
|
||||
if existing:
|
||||
existing.samples, existing.laps, existing.metrics = samples, laps, metrics
|
||||
persist_efforts(existing)
|
||||
return existing
|
||||
row = Activity(
|
||||
owner_id=owner_id,
|
||||
@@ -125,6 +127,7 @@ def activity_from_fit(owner_id, source_key, documents, metadata=None, refresh=Fa
|
||||
samples=samples,
|
||||
laps=laps,
|
||||
)
|
||||
persist_efforts(row)
|
||||
db.session.add(row)
|
||||
return row
|
||||
|
||||
|
||||
Reference in New Issue
Block a user