diff --git a/local_backend/services/cloud_sync.py b/local_backend/services/cloud_sync.py index 712844d..9c25367 100644 --- a/local_backend/services/cloud_sync.py +++ b/local_backend/services/cloud_sync.py @@ -446,8 +446,19 @@ async def _push_stats_snapshot(): async def _connect_loop(): """Faster loop: pulls pending online orders every CONNECT_SYNC_INTERVAL_SECONDS. - Also pushes menu snapshot and stats every 5 minutes (piggybacking on this loop).""" + Also pushes menu snapshot and stats every 5 minutes (piggybacking on this loop). + On startup, waits for the first heartbeat to populate site_numeric_id then + immediately pushes menu + stats without waiting a full cycle.""" push_every = max(1, (5 * 60) // ORDER_POLL_INTERVAL) + + # Wait for the heartbeat loop to get site_numeric_id, then do an immediate push + for _ in range(30): # wait up to 30 seconds + if license_state.get("site_numeric_id"): + break + await asyncio.sleep(1) + await _push_menu_snapshot() + await _push_stats_snapshot() + tick = 0 while True: await asyncio.sleep(ORDER_POLL_INTERVAL)