Cut Garmin sync API volume; dashboard/health/records/UI improvements
Garmin Connect sync: - Incremental syncs now re-fetch only a 1-day buffer (yesterday + today) instead of the full lookback window every run. Full lookback applies on the first sync only. Cuts steady-state API calls ~10x. - Beat interval is now configurable via GARMIN_SYNC_INTERVAL_MINUTES and surfaced to the UI; the sync toggle is relabelled to the real cadence. Frontend: - Collapsible sidebar; clearer logged-in user + role display. - Unified Body Battery colouring between dashboard and health (shared util). - Sleep score trend chart on health page. - Segments + medals on the dashboard's most-recent activity. - Segments tab on the Records page. Repo hygiene: add .gitignore, untrack committed __pycache__/*.pyc. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -7,6 +7,7 @@ from datetime import datetime
|
||||
|
||||
from app.core.database import get_db
|
||||
from app.core.security import get_current_user
|
||||
from app.core.config import settings
|
||||
from app.models.user import User, GarminConnectConfig
|
||||
|
||||
router = APIRouter()
|
||||
@@ -27,6 +28,7 @@ class GarminConfigOut(BaseModel):
|
||||
sync_activities: bool
|
||||
sync_wellness: bool
|
||||
sync_lookback_days: int
|
||||
sync_interval_minutes: int # how often the automatic sync runs
|
||||
last_sync_at: Optional[datetime]
|
||||
last_sync_status: Optional[str]
|
||||
connected: bool
|
||||
@@ -48,6 +50,7 @@ async def get_config(
|
||||
return GarminConfigOut(
|
||||
email="", sync_enabled=False, sync_activities=True,
|
||||
sync_wellness=True, sync_lookback_days=30,
|
||||
sync_interval_minutes=settings.garmin_sync_interval_minutes,
|
||||
last_sync_at=None, last_sync_status=None, connected=False,
|
||||
)
|
||||
return GarminConfigOut(
|
||||
@@ -56,6 +59,7 @@ async def get_config(
|
||||
sync_activities=cfg.sync_activities,
|
||||
sync_wellness=cfg.sync_wellness,
|
||||
sync_lookback_days=cfg.sync_lookback_days if cfg.sync_lookback_days is not None else 30,
|
||||
sync_interval_minutes=settings.garmin_sync_interval_minutes,
|
||||
last_sync_at=cfg.last_sync_at,
|
||||
last_sync_status=cfg.last_sync_status,
|
||||
connected=True,
|
||||
@@ -121,6 +125,7 @@ async def save_config(
|
||||
sync_activities=cfg.sync_activities,
|
||||
sync_wellness=cfg.sync_wellness,
|
||||
sync_lookback_days=cfg.sync_lookback_days if cfg.sync_lookback_days is not None else 30,
|
||||
sync_interval_minutes=settings.garmin_sync_interval_minutes,
|
||||
last_sync_at=cfg.last_sync_at,
|
||||
last_sync_status=cfg.last_sync_status,
|
||||
connected=True,
|
||||
|
||||
Reference in New Issue
Block a user