diff --git a/internal/aggregate/geo_enrich.go b/internal/aggregate/geo_enrich.go index 2d8d84d..a052f25 100644 --- a/internal/aggregate/geo_enrich.go +++ b/internal/aggregate/geo_enrich.go @@ -28,7 +28,9 @@ func EnrichUniqueIPsGeo(rows []UniqueIPsRow, g *geoip.Service) { s := res.CityName rows[i].IPs[j].CityName = &s } - if res.Latitude != 0 || res.Longitude != 0 { + // Заполняем координаты если GeoIP нашёл геоданные (страна/город), + // даже если координаты оказались 0.0 (иначе карта может быть пустой). + if res.CountryCode != "" || res.CountryName != "" || res.CityName != "" { lat := res.Latitude lon := res.Longitude rows[i].IPs[j].Latitude = &lat diff --git a/internal/geoip/geoip.go b/internal/geoip/geoip.go index 06a55dd..fd13ff5 100644 --- a/internal/geoip/geoip.go +++ b/internal/geoip/geoip.go @@ -101,13 +101,11 @@ func (s *Service) Lookup(ipStr string) (Result, bool) { if rec.City.Names != nil { out.CityName = rec.City.Names["en"] } - // Coordinates are used by the UI map. - // Note: MaxMind might still return 0/0 for unknown locations. - if rec.Location.Latitude != 0 || rec.Location.Longitude != 0 { - out.Latitude = rec.Location.Latitude - out.Longitude = rec.Location.Longitude - ok = true - } + // Для карты важны координаты. Даже если MaxMind вернул (0,0), + // лучше прокидывать их дальше, чем скрывать все точки. + out.Latitude = rec.Location.Latitude + out.Longitude = rec.Location.Longitude + if out.CountryCode != "" || out.CountryName != "" || out.CityName != "" { ok = true }