diff --git a/internal/database/database.go b/internal/database/database.go index 2e58561..bf03e21 100644 --- a/internal/database/database.go +++ b/internal/database/database.go @@ -767,11 +767,12 @@ func (d *Database) GetASDetails(asn int) (*ASN, []LiveRoute, error) { asnInfo.Handle = handle.String asnInfo.Description = description.String - // Get prefixes announced by this AS + // Get prefixes announced by this AS (unique prefixes with most recent update) query := ` - SELECT DISTINCT prefix, mask_length, ip_version, last_updated + SELECT prefix, mask_length, ip_version, MAX(last_updated) as last_updated FROM live_routes WHERE origin_asn = ? + GROUP BY prefix, mask_length, ip_version ORDER BY ip_version, mask_length, prefix `