Show the prefix page's origin names from the prefix query (closes #67)
check / check (push) Waiting to run

The prefix page looked up each origin AS's details only for its handle and
description, and that lookup also reads every live route the AS originates.
GetPrefixDetailsContext already selects the handle and description; it now
returns them keyed by AS number, and the page uses them instead.

The origin list was handed each description but never rendered it; it now
shows it after the handle.

Model: opus-5-5
This commit is contained in:
2026-10-14 15:28:24 +00:00
parent 616f13071f
commit fb8ffe9b97
7 changed files with 97 additions and 25 deletions
+4 -12
View File
@@ -759,7 +759,7 @@ func (s *Server) handlePrefixDetailJSON() http.HandlerFunc {
}
prefix := parsed.Masked().String()
routes, err := s.db.GetPrefixDetailsContext(r.Context(), prefix)
routes, _, err := s.db.GetPrefixDetailsContext(r.Context(), prefix)
if err != nil {
if errors.Is(err, database.ErrNoRoute) {
writeJSONError(w, http.StatusNotFound, err.Error())
@@ -930,7 +930,7 @@ func (s *Server) handlePrefixDetail() http.HandlerFunc {
}
prefix := parsed.Masked().String()
routes, err := s.db.GetPrefixDetailsContext(r.Context(), prefix)
routes, originASNs, err := s.db.GetPrefixDetailsContext(r.Context(), prefix)
if err != nil {
if errors.Is(err, database.ErrNoRoute) {
http.Error(w, "Prefix not found", http.StatusNotFound)
@@ -952,18 +952,10 @@ func (s *Server) handlePrefixDetail() http.HandlerFunc {
originMap := make(map[int]*ASNInfo)
for _, route := range routes {
if _, exists := originMap[route.OriginASN]; !exists {
// Get AS info from database
asInfo, _, _ := s.db.GetASDetailsContext(r.Context(), route.OriginASN)
handle := ""
description := ""
if asInfo != nil {
handle = asInfo.Handle
description = asInfo.Description
}
originMap[route.OriginASN] = &ASNInfo{
ASN: route.OriginASN,
Handle: handle,
Description: description,
Handle: originASNs[route.OriginASN].Handle,
Description: originASNs[route.OriginASN].Description,
PeerCount: 0,
}
}