From 8cd356e47989fa95f1baabc6e935cbc80ea40a40 Mon Sep 17 00:00:00 2001 From: MikeO7 Date: Sun, 19 Oct 2025 21:18:54 -0600 Subject: [PATCH] Prowlarr Statistics UI Improvements: Fixed Display Issues and Removed Redundant Metrics MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changes Made Frontend (frontend/static/js/new-main.js) ✅ Added "Grabs Today" metric - Now displays daily successful grabs alongside searches ✅ Removed "Total Searches" metric - Eliminated confusing duplicate that showed same value as "Searches Today" ✅ Simplified Success Rate colors - Changed from 3-tier threshold (80%/60%/error) to simple binary: green if > 0%, red if 0% ✅ Removed dead code - Deleted unused loadProwlarrStats() and updateProwlarrStatsDisplay() functions (62 lines) that referenced non-existent HTML elements Frontend CSS (frontend/templates/components/home_section.html) ✅ Fixed Success Rate card visibility - Label was being cut off due to insufficient height ✅ Standardized card sizing - All stat cards now uniform height (60px) with consistent padding (10px 12px) ✅ Adjusted typography - Reduced label font-size to 0.7em and value font-size to 1.3em for better fit ✅ Added explicit overrides - Used !important on Prowlarr stats to prevent inherited padding/margin issues ✅ Improved alignment - Added align-items: center for consistent vertical centering Backend (src/primary/apps/prowlarr_routes.py) ✅ Removed total_api_calls tracking - No longer calculated or stored in stats ✅ Removed unnecessary API calls - Deleted code attempting to fetch lifetime totals from Prowlarr ✅ Added grabs_today to stats - Now properly tracked and returned in API responses ✅ Cleaned up logging - Removed references to total_api_calls from debug messages ✅ Updated indexer stats endpoint - Returns grabs_today instead of total_api_calls --- frontend/static/js/new-main.js | 86 +++---------------- .../templates/components/home_section.html | 21 +++-- src/primary/apps/prowlarr_routes.py | 13 +-- 3 files changed, 29 insertions(+), 91 deletions(-) diff --git a/frontend/static/js/new-main.js b/frontend/static/js/new-main.js index aad835ec..c61a67ad 100644 --- a/frontend/static/js/new-main.js +++ b/frontend/static/js/new-main.js @@ -2519,68 +2519,6 @@ let huntarrUI = { }); }, - // Load detailed Prowlarr statistics - loadProwlarrStats: function() { - HuntarrUtils.fetchWithTimeout('./api/prowlarr/stats') - .then(response => response.json()) - .then(data => { - if (data.success) { - this.updateProwlarrStatsDisplay(data.stats); - } else { - console.error('Failed to load Prowlarr stats:', data.error); - this.updateProwlarrStatsDisplay({ - active_indexers: '--', - total_api_calls: '--', - throttled_indexers: '--', - failed_indexers: '--', - health_status: 'Error loading stats' - }); - } - }) - .catch(error => { - console.error('Error loading Prowlarr stats:', error); - this.updateProwlarrStatsDisplay({ - active_indexers: '--', - total_api_calls: '--', - throttled_indexers: '--', - failed_indexers: '--', - health_status: 'Connection error' - }); - }); - }, - - // Update Prowlarr stats display - updateProwlarrStatsDisplay: function(stats) { - // Update stat numbers - const activeElement = document.getElementById('prowlarr-active-indexers'); - if (activeElement) activeElement.textContent = stats.active_indexers; - - const callsElement = document.getElementById('prowlarr-total-calls'); - if (callsElement) callsElement.textContent = this.formatLargeNumber(stats.total_api_calls); - - const throttledElement = document.getElementById('prowlarr-throttled'); - if (throttledElement) throttledElement.textContent = stats.throttled_indexers; - - const failedElement = document.getElementById('prowlarr-failed'); - if (failedElement) failedElement.textContent = stats.failed_indexers; - - // Update health status - const healthElement = document.getElementById('prowlarr-health-status'); - if (healthElement) { - healthElement.textContent = stats.health_status || 'Unknown'; - - // Add color coding based on health - if (stats.health_status && stats.health_status.includes('throttled')) { - healthElement.style.color = '#f59e0b'; // amber - } else if (stats.health_status && (stats.health_status.includes('failed') || stats.health_status.includes('disabled'))) { - healthElement.style.color = '#ef4444'; // red - } else if (stats.health_status && stats.health_status.includes('healthy')) { - healthElement.style.color = '#10b981'; // green - } else { - healthElement.style.color = '#9ca3af'; // gray - } - } - }, // Load Prowlarr indexers quickly loadProwlarrIndexers: function() { @@ -2733,13 +2671,23 @@ let huntarrUI = { `); } + // Grabs Today + if (stats.grabs_today !== undefined) { + const grabsClass = stats.grabs_today > 0 ? 'success' : ''; + statisticsCards.push(` +
+
Grabs Today
+
${stats.grabs_today}
+
+ `); + } + // Success rate (always show, even if 0 or undefined) let successRate = 0; if (stats.recent_success_rate !== undefined && stats.recent_success_rate !== null) { successRate = stats.recent_success_rate; } - const successClass = successRate >= 80 ? 'success' : - successRate >= 60 ? 'warning' : 'error'; + const successClass = successRate > 0 ? 'success' : 'error'; statisticsCards.push(`
Success Rate
@@ -2763,16 +2711,6 @@ let huntarrUI = { `); } - // Total API calls - if (stats.total_api_calls !== undefined) { - statisticsCards.push(` -
-
Total Searches
-
${stats.total_api_calls.toLocaleString()}
-
- `); - } - // Failed searches (only show if > 0) if (stats.recent_failed_searches !== undefined && stats.recent_failed_searches > 0) { statisticsCards.push(` diff --git a/frontend/templates/components/home_section.html b/frontend/templates/components/home_section.html index f1136fbc..94c5b1d5 100644 --- a/frontend/templates/components/home_section.html +++ b/frontend/templates/components/home_section.html @@ -806,7 +806,7 @@

Swaparr Status

background: linear-gradient(135deg, rgba(16, 20, 28, 0.8) 0%, rgba(30, 35, 45, 0.6) 100%); border: 1px solid rgba(90, 109, 137, 0.15); border-radius: 8px; - padding: 12px; + padding: 10px 12px; text-align: center; position: relative; overflow: hidden; @@ -815,6 +815,7 @@

Swaparr Status

display: flex; flex-direction: column; justify-content: center; + align-items: center; } .stat-card:hover { @@ -840,29 +841,33 @@

Swaparr Status

} .stat-label { - font-size: 0.75em; + font-size: 0.7em; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; - margin-bottom: 2px; + margin-bottom: 4px; font-weight: 500; line-height: 1; } .stat-value { - font-size: 1.4em; + font-size: 1.3em; font-weight: 700; color: var(--text-primary); line-height: 1; } /* Ensure Success Rate label shows and values match other stats sizing */ - .prowlarr-statistics-card .stat-label { - display: block; - opacity: 1; + .prowlarr-statistics-card .stat-card .stat-label { + display: block !important; + opacity: 1 !important; + visibility: visible !important; } .prowlarr-statistics-card .stat-value { - font-size: 1.4em; /* keep consistent with other stat values */ + font-size: 1.3em !important; + line-height: 1 !important; + padding: 0 !important; + margin: 0 !important; } .stat-value.success { diff --git a/src/primary/apps/prowlarr_routes.py b/src/primary/apps/prowlarr_routes.py index 3ec677a3..2ca4d75a 100644 --- a/src/primary/apps/prowlarr_routes.py +++ b/src/primary/apps/prowlarr_routes.py @@ -307,7 +307,6 @@ def _fetch_detailed_stats(): 'recent_success_rate': 0, 'recent_failed_searches': 0, 'avg_response_time': 0, - 'total_api_calls': 0, 'indexer_performance': [] } @@ -361,9 +360,6 @@ def _fetch_detailed_stats(): prowlarr_logger.debug(f"Fallback: Retrieved {len(all_records)} history records from regular endpoint") if all_records: - # Total records gives us approximate API call count - stats['total_api_calls'] = len(all_records) - # Analyze recent activity (overall and per indexer) searches_today = 0 @@ -484,11 +480,10 @@ def _fetch_detailed_stats(): else: stats['recent_success_rate'] = 0 - # Update total API calls to match indexerstats - stats['total_api_calls'] = sum(stat.get('numberOfQueries', 0) for stat in indexer_stats) stats['recent_failed_searches'] = total_failed + stats['grabs_today'] = total_grabs # Add total grabs to stats - prowlarr_logger.debug(f"Main stats updated - Success rate: {stats['recent_success_rate']}%, Total API calls: {stats['total_api_calls']}, Failed: {total_failed}") + prowlarr_logger.debug(f"Main stats updated - Success rate: {stats['recent_success_rate']}%, Failed today: {total_failed}") # Debug logging to track individual indexer contributions for idx_id, idx_data in stats.get('indexer_daily_stats', {}).items(): @@ -664,8 +659,8 @@ def get_indexer_stats(indexer_name): 'searches_today': indexer_data['searches_today'], 'recent_success_rate': indexer_data['today_success_rate'], 'avg_response_time': indexer_data['response_time'], - 'total_api_calls': indexer_data['queries'], - 'recent_failed_searches': indexer_data['failed_today'] + 'recent_failed_searches': indexer_data['failed_today'], + 'grabs_today': indexer_data['grabs'] }, 'cached': True })