From 48db8b9edf4d4d56c78ea539e13b2564f5f87b53 Mon Sep 17 00:00:00 2001 From: sneak Date: Mon, 28 Jul 2025 04:36:22 +0200 Subject: [PATCH] Fix AS detail view to show unique prefixes - Update GetASDetails query to GROUP BY prefix instead of using DISTINCT - Use MAX(last_updated) to get the most recent update time for each prefix - This prevents duplicate prefixes from appearing when announced by multiple peers - Maintains the same prefix count and ordering --- internal/database/database.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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 `