Implement planet name resolution

This commit is contained in:
2025-10-10 23:07:10 +02:00
parent 8f0c027218
commit ac6495faf0
3 changed files with 96 additions and 20 deletions

View File

@@ -269,6 +269,15 @@ func (rh *RouteHandler) handleGetExtractors(ctx *fasthttp.RequestCtx) {
}
if details != nil {
// Get planet name from universe endpoint
planetNameData, err := rh.ESI.GetPlanetName(context.Background(), planet.PlanetID)
if err != nil {
logger.Error("Failed to get planet name for planet ID %d: %v", planet.PlanetID, err)
ctx.SetStatusCode(fasthttp.StatusInternalServerError)
ctx.SetBodyString("Failed to get planet name")
return
}
// Count extractors and get expiry dates
extractorCount := 0
for _, pin := range details.Pins {
@@ -279,17 +288,8 @@ func (rh *RouteHandler) handleGetExtractors(ctx *fasthttp.RequestCtx) {
expiryDate = *pin.ExpiryTime
}
// Get actual planet name - if empty, this is an error
planetName := planet.PlanetName
if planetName == "" {
logger.Error("Planet name is empty for planet ID %d", planet.PlanetID)
ctx.SetStatusCode(fasthttp.StatusInternalServerError)
ctx.SetBodyString("Planet name is empty - this should not happen")
return
}
extractors = append(extractors, ExtractorInfo{
PlanetName: planetName,
PlanetName: planetNameData.Name,
ExtractorNumber: extractorCount,
ExpiryDate: expiryDate,
})
@@ -338,6 +338,15 @@ func (rh *RouteHandler) handleGetStorage(ctx *fasthttp.RequestCtx) {
}
if details != nil {
// Get planet name from universe endpoint
planetNameData, err := rh.ESI.GetPlanetName(context.Background(), planet.PlanetID)
if err != nil {
logger.Error("Failed to get planet name for planet ID %d: %v", planet.PlanetID, err)
ctx.SetStatusCode(fasthttp.StatusInternalServerError)
ctx.SetBodyString("Failed to get planet name")
return
}
// Analyze storage utilization
for _, pin := range details.Pins {
if len(pin.Contents) > 0 {
@@ -347,15 +356,6 @@ func (rh *RouteHandler) handleGetStorage(ctx *fasthttp.RequestCtx) {
totalAmount += content.Amount
}
// Get actual planet name - if empty, this is an error
planetName := planet.PlanetName
if planetName == "" {
logger.Error("Planet name is empty for planet ID %d", planet.PlanetID)
ctx.SetStatusCode(fasthttp.StatusInternalServerError)
ctx.SetBodyString("Planet name is empty - this should not happen")
return
}
// Determine storage type based on pin type
storageType := "Unknown"
switch pin.TypeID {
@@ -372,7 +372,7 @@ func (rh *RouteHandler) handleGetStorage(ctx *fasthttp.RequestCtx) {
}
storage = append(storage, StorageInfo{
PlanetName: planetName,
PlanetName: planetNameData.Name,
StorageType: storageType,
Utilization: utilization,
})