Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 12 additions & 74 deletions frontend/static/js/new-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -2733,13 +2671,23 @@ let huntarrUI = {
`);
}

// Grabs Today
if (stats.grabs_today !== undefined) {
const grabsClass = stats.grabs_today > 0 ? 'success' : '';
statisticsCards.push(`
<div class="stat-card">
<div class="stat-label">Grabs Today</div>
<div class="stat-value ${grabsClass}">${stats.grabs_today}</div>
</div>
`);
}

// 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(`
<div class="stat-card">
<div class="stat-label">Success Rate</div>
Expand All @@ -2763,16 +2711,6 @@ let huntarrUI = {
`);
}

// Total API calls
if (stats.total_api_calls !== undefined) {
statisticsCards.push(`
<div class="stat-card">
<div class="stat-label">Total Searches</div>
<div class="stat-value">${stats.total_api_calls.toLocaleString()}</div>
</div>
`);
}

// Failed searches (only show if > 0)
if (stats.recent_failed_searches !== undefined && stats.recent_failed_searches > 0) {
statisticsCards.push(`
Expand Down
21 changes: 13 additions & 8 deletions frontend/templates/components/home_section.html
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,7 @@ <h3><i class="fas fa-download"></i> Swaparr Status</h3>
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;
Expand All @@ -815,6 +815,7 @@ <h3><i class="fas fa-download"></i> Swaparr Status</h3>
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}

.stat-card:hover {
Expand All @@ -840,29 +841,33 @@ <h3><i class="fas fa-download"></i> Swaparr Status</h3>
}

.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 {
Expand Down
13 changes: 4 additions & 9 deletions src/primary/apps/prowlarr_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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': []
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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():
Expand Down Expand Up @@ -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
})
Expand Down