fix: push menu + stats immediately on startup instead of waiting first cycle
_connect_loop now waits up to 30 seconds for the heartbeat to return site_numeric_id, then immediately pushes the menu snapshot and stats before entering the regular poll loop. Previously the first push wouldn't fire until 5 minutes after startup, making the menu unavailable until then. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -446,8 +446,19 @@ async def _push_stats_snapshot():
|
|||||||
|
|
||||||
async def _connect_loop():
|
async def _connect_loop():
|
||||||
"""Faster loop: pulls pending online orders every CONNECT_SYNC_INTERVAL_SECONDS.
|
"""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)
|
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
|
tick = 0
|
||||||
while True:
|
while True:
|
||||||
await asyncio.sleep(ORDER_POLL_INTERVAL)
|
await asyncio.sleep(ORDER_POLL_INTERVAL)
|
||||||
|
|||||||
Reference in New Issue
Block a user