From 5adfdad9a3871d2cea012fb01f30636922af1527 Mon Sep 17 00:00:00 2001 From: Broque Thomas <26755000+Nezreka@users.noreply.github.com> Date: Wed, 18 Mar 2026 15:02:00 -0700 Subject: [PATCH] Speed up dashboard polling intervals for more responsive UI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Service status 10s→5s, activity feed 5s→2s, watchlist/wishlist/db stats 30s→10s. --- web_server.py | 20 ++++++++++---------- webui/static/script.js | 18 +++++++++--------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/web_server.py b/web_server.py index 2bce2b2a..e717fcdc 100644 --- a/web_server.py +++ b/web_server.py @@ -41190,18 +41190,18 @@ def _build_watchlist_count_payload(profile_id=1): } def _emit_service_status_loop(): - """Background thread that pushes service status every 10 seconds.""" + """Background thread that pushes service status every 5 seconds.""" while True: - socketio.sleep(10) + socketio.sleep(5) try: socketio.emit('status:update', _build_status_payload()) except Exception as e: logger.debug(f"Error emitting service status: {e}") def _emit_watchlist_count_loop(): - """Background thread that pushes watchlist count every 30 seconds to each profile room.""" + """Background thread that pushes watchlist count every 10 seconds to each profile room.""" while True: - socketio.sleep(30) + socketio.sleep(10) try: database = get_database() profiles = database.get_all_profiles() @@ -41282,9 +41282,9 @@ def _emit_system_stats_loop(): logger.debug(f"Error emitting system stats: {e}") def _emit_activity_feed_loop(): - """Background thread that pushes activity feed every 5 seconds.""" + """Background thread that pushes activity feed every 2 seconds.""" while True: - socketio.sleep(5) + socketio.sleep(2) try: with activity_feed_lock: activities = activity_feed[-10:][::-1] @@ -41293,9 +41293,9 @@ def _emit_activity_feed_loop(): logger.debug(f"Error emitting activity feed: {e}") def _emit_db_stats_loop(): - """Background thread that pushes database stats every 30 seconds.""" + """Background thread that pushes database stats every 10 seconds.""" while True: - socketio.sleep(30) + socketio.sleep(10) try: db = get_database() stats = db.get_database_info_for_server() @@ -41304,9 +41304,9 @@ def _emit_db_stats_loop(): logger.debug(f"Error emitting db stats: {e}") def _emit_wishlist_count_loop(): - """Background thread that pushes wishlist count every 30 seconds to each profile room.""" + """Background thread that pushes wishlist count every 10 seconds to each profile room.""" while True: - socketio.sleep(30) + socketio.sleep(10) try: from core.wishlist_service import get_wishlist_service ws = get_wishlist_service() diff --git a/webui/static/script.js b/webui/static/script.js index 2ba0e0c4..a3657997 100644 --- a/webui/static/script.js +++ b/webui/static/script.js @@ -1896,7 +1896,7 @@ function initApp() { // Start global service status polling for sidebar (works on all pages) // Initial fetch for immediate data, then setInterval as fallback when WebSocket is disconnected fetchAndUpdateServiceStatus(); - setInterval(fetchAndUpdateServiceStatus, 10000); // Every 10 seconds (no-op when WebSocket active) + setInterval(fetchAndUpdateServiceStatus, 5000); // Every 5 seconds (no-op when WebSocket active) // Check for updates on load and every hour checkForUpdates(); @@ -2008,8 +2008,8 @@ function initializeWatchlist() { // Update watchlist count initially updateWatchlistButtonCount(); - // Update count every 30 seconds - setInterval(updateWatchlistButtonCount, 30000); + // Update count every 10 seconds + setInterval(updateWatchlistButtonCount, 10000); console.log('Watchlist system initialized'); } @@ -21228,9 +21228,9 @@ async function loadDashboardData() { // Initial load of stats await fetchAndUpdateDbStats(); - // Start periodic refresh of stats (every 30 seconds) + // Start periodic refresh of stats (every 10 seconds) stopDbStatsPolling(); // Ensure no duplicates - dbStatsInterval = setInterval(fetchAndUpdateDbStats, 30000); + dbStatsInterval = setInterval(fetchAndUpdateDbStats, 10000); // Initial load of discovery pool stats for the tool card loadDiscoveryPoolStats(); @@ -21241,9 +21241,9 @@ async function loadDashboardData() { // Initial load of wishlist count await updateWishlistCount(); - // Start periodic refresh of wishlist count (every 30 seconds, matching GUI behavior) + // Start periodic refresh of wishlist count (every 10 seconds) stopWishlistCountPolling(); // Ensure no duplicates - wishlistCountInterval = setInterval(updateWishlistCount, 30000); + wishlistCountInterval = setInterval(updateWishlistCount, 10000); // Initial load of service status and system statistics await fetchAndUpdateServiceStatus(); @@ -21256,8 +21256,8 @@ async function loadDashboardData() { // Initial load of activity feed await fetchAndUpdateActivityFeed(); - // Start periodic refresh of activity feed (every 5 seconds for responsiveness) - setInterval(fetchAndUpdateActivityFeed, 5000); + // Start periodic refresh of activity feed (every 2 seconds for responsiveness) + setInterval(fetchAndUpdateActivityFeed, 2000); // Start periodic toast checking (every 3 seconds) setInterval(checkForActivityToasts, 3000);