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() {
|
async function pollServerHealth() {
|
||||||
try {
|
try {
|
||||||
const response = await fetch(`${API_BASE}/server-health`);
|
const response = await fetch(`${API_BASE}/server-health`);
|
||||||
|
|
@ -1248,10 +1265,13 @@ function startPolling() {
|
||||||
if (pollID !== null) return;
|
if (pollID !== null) return;
|
||||||
pollLive();
|
pollLive();
|
||||||
pollTotalRares(); // Initial fetch
|
pollTotalRares(); // Initial fetch
|
||||||
|
pollTotalKills(); // Initial fetch
|
||||||
pollServerHealth(); // Initial server health check
|
pollServerHealth(); // Initial server health check
|
||||||
pollID = setInterval(pollLive, POLL_MS);
|
pollID = setInterval(pollLive, POLL_MS);
|
||||||
// Poll total rares every 5 minutes (300,000 ms)
|
// Poll total rares every 5 minutes (300,000 ms)
|
||||||
setInterval(pollTotalRares, 300000);
|
setInterval(pollTotalRares, 300000);
|
||||||
|
// Poll total kills every 5 minutes (300,000 ms)
|
||||||
|
setInterval(pollTotalKills, 300000);
|
||||||
// Poll server health every 30 seconds (30,000 ms)
|
// Poll server health every 30 seconds (30,000 ms)
|
||||||
setInterval(pollServerHealth, 30000);
|
setInterval(pollServerHealth, 30000);
|
||||||
}
|
}
|
||||||
|
|
@ -1324,14 +1344,8 @@ function render(players) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate and update total kills
|
// Total kills is now fetched from the /total-kills/ API endpoint
|
||||||
const totalKills = players.reduce((sum, p) => sum + (p.total_kills || 0), 0);
|
// (see pollTotalKills function) to include ALL characters, not just online ones
|
||||||
const killsElement = document.getElementById('totalKillsCount');
|
|
||||||
if (killsElement) {
|
|
||||||
// Format with commas for readability
|
|
||||||
const formattedKills = totalKills.toLocaleString();
|
|
||||||
killsElement.textContent = formattedKills;
|
|
||||||
}
|
|
||||||
|
|
||||||
players.forEach(p => {
|
players.forEach(p => {
|
||||||
const { x, y } = worldToPx(p.ew, p.ns);
|
const { x, y } = worldToPx(p.ew, p.ns);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue