Fetch total kills from API instead of calculating from online players
Total kills now comes from the /total-kills/ API endpoint which includes ALL characters in the database, not just currently online players. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
42d5dab319
commit
4e0306cd01
1 changed files with 22 additions and 8 deletions
|
|
@ -1173,6 +1173,23 @@ function updateTotalRaresDisplay(data) {
|
|||
}
|
||||
}
|
||||
|
||||
async function pollTotalKills() {
|
||||
try {
|
||||
const response = await fetch(`${API_BASE}/total-kills/`);
|
||||
const data = await response.json();
|
||||
updateTotalKillsDisplay(data);
|
||||
} catch (e) {
|
||||
console.error('Total kills fetch failed:', e);
|
||||
}
|
||||
}
|
||||
|
||||
function updateTotalKillsDisplay(data) {
|
||||
const killsElement = document.getElementById('totalKillsCount');
|
||||
if (killsElement && data.total !== undefined) {
|
||||
killsElement.textContent = data.total.toLocaleString();
|
||||
}
|
||||
}
|
||||
|
||||
async function pollServerHealth() {
|
||||
try {
|
||||
const response = await fetch(`${API_BASE}/server-health`);
|
||||
|
|
@ -1248,10 +1265,13 @@ function startPolling() {
|
|||
if (pollID !== null) return;
|
||||
pollLive();
|
||||
pollTotalRares(); // Initial fetch
|
||||
pollTotalKills(); // Initial fetch
|
||||
pollServerHealth(); // Initial server health check
|
||||
pollID = setInterval(pollLive, POLL_MS);
|
||||
// Poll total rares every 5 minutes (300,000 ms)
|
||||
setInterval(pollTotalRares, 300000);
|
||||
// Poll total kills every 5 minutes (300,000 ms)
|
||||
setInterval(pollTotalKills, 300000);
|
||||
// Poll server health every 30 seconds (30,000 ms)
|
||||
setInterval(pollServerHealth, 30000);
|
||||
}
|
||||
|
|
@ -1324,14 +1344,8 @@ function render(players) {
|
|||
}
|
||||
}
|
||||
|
||||
// Calculate and update total kills
|
||||
const totalKills = players.reduce((sum, p) => sum + (p.total_kills || 0), 0);
|
||||
const killsElement = document.getElementById('totalKillsCount');
|
||||
if (killsElement) {
|
||||
// Format with commas for readability
|
||||
const formattedKills = totalKills.toLocaleString();
|
||||
killsElement.textContent = formattedKills;
|
||||
}
|
||||
// Total kills is now fetched from the /total-kills/ API endpoint
|
||||
// (see pollTotalKills function) to include ALL characters, not just online ones
|
||||
|
||||
players.forEach(p => {
|
||||
const { x, y } = worldToPx(p.ew, p.ns);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue