fix: Implement dynamic age calculation for aircraft tracking
Resolves issue #3 where aircraft age field was always showing 0 seconds. Backend Changes: - Fix MarshalJSON in merger.go to calculate age dynamically using time.Since(a.LastUpdate) - Add comprehensive tests for age calculation in merger_test.go Frontend Changes: - Add calculateAge() utility method to both aircraft-manager.js and ui-manager.js - Update popup content and aircraft table to use client-side age calculation - Implement real-time age updates every second in app.js - Add updateOpenPopupAges() function to refresh popup displays Key Benefits: - Aircraft age now shows actual seconds since last transmission - Real-time updates in UI without requiring new WebSocket data - Proper data staleness indicators for aviation tracking - No additional server load - client-side calculation using last_update timestamp 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
6efd673507
commit
10508c2dc6
5 changed files with 145 additions and 3 deletions
|
|
@ -469,10 +469,40 @@ class SkyView {
|
|||
this.radar3d.renderer.render(this.radar3d.scene, this.radar3d.camera);
|
||||
}
|
||||
|
||||
updateOpenPopupAges() {
|
||||
// Find any open aircraft popups and update their age displays
|
||||
if (!this.aircraftManager) return;
|
||||
|
||||
this.aircraftManager.aircraftMarkers.forEach((marker, icao) => {
|
||||
if (marker.isPopupOpen()) {
|
||||
const aircraft = this.aircraftManager.aircraftData.get(icao);
|
||||
if (aircraft) {
|
||||
// Refresh the popup content with current age
|
||||
marker.setPopupContent(this.aircraftManager.createPopupContent(aircraft));
|
||||
|
||||
// Re-enhance callsign display for the updated popup
|
||||
const popupElement = marker.getPopup().getElement();
|
||||
if (popupElement) {
|
||||
this.aircraftManager.enhanceCallsignDisplay(popupElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
startPeriodicTasks() {
|
||||
// Update clocks every second
|
||||
setInterval(() => this.uiManager.updateClocks(), 1000);
|
||||
|
||||
// Update aircraft ages and refresh displays every second
|
||||
setInterval(() => {
|
||||
// Update aircraft table to show current ages
|
||||
this.uiManager.updateAircraftTable();
|
||||
|
||||
// Update any open aircraft popups with current ages
|
||||
this.updateOpenPopupAges();
|
||||
}, 1000);
|
||||
|
||||
// Update charts every 10 seconds
|
||||
setInterval(() => this.updateCharts(), 10000);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue