fix: handle all ES geo_point formats from Cesium+

Cesium+ stores geoPoint in multiple Elasticsearch formats (object,
string "lat,lon", array [lon,lat]). Using z.object() caused a ZodError
that silently swallowed the entire Cesium+ response, leaving geoMap
empty and displaying 0 geolocalized transactions.

Replace the strict Zod schema with z.unknown() and a parseGeoPoint()
helper that normalizes all three formats. Also add [GéoFlux] debug
logs to DataService to trace keyMap/duniterKeys/geoMap pipeline steps.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
syoul
2026-03-22 18:12:15 +01:00
parent 9265517c52
commit a288a5b2e7
2 changed files with 39 additions and 12 deletions

View File

@@ -47,14 +47,16 @@ async function fetchLiveTransactions(periodDays: number): Promise<{
let keyMap = new Map<string, string>();
try {
keyMap = await getIdentityKeyMap();
console.log('[GéoFlux] keyMap:', keyMap.size, 'entrées');
} catch (err) {
console.warn('Identity key map indisponible :', err);
console.error('[GéoFlux] Identity key map ERREUR:', err);
}
// Clés Duniter uniques des émetteurs
const duniterKeys = [...new Set(
rawTransfers.map((t) => keyMap.get(t.fromId)).filter(Boolean) as string[]
)];
console.log('[GéoFlux] duniterKeys:', duniterKeys.length);
// Résolution géo par clé Duniter (_id Cesium+)
let geoMap = new Map<string, { lat: number; lng: number; city: string }>();
@@ -63,8 +65,9 @@ async function fetchLiveTransactions(periodDays: number): Promise<{
for (const [key, p] of profiles) {
geoMap.set(key, { lat: p.lat, lng: p.lng, city: p.city });
}
console.log('[GéoFlux] geoMap:', geoMap.size, 'entrées');
} catch (err) {
console.warn('Cesium+ indisponible :', err);
console.error('[GéoFlux] Cesium+ ERREUR:', err);
}
// Seules les transactions avec un profil géo entrent dans le heatmap