Wire everything up

This commit is contained in:
2025-10-11 10:51:55 +02:00
parent 22b218c7d3
commit 77287c6361
3 changed files with 60 additions and 53 deletions

View File

@@ -150,7 +150,7 @@ func (rh *RouteHandler) handlePlanetDetails(ctx *fasthttp.RequestCtx) {
}
// Fetch planet details using ESI API
planetDetail, err := rh.ESI.GetPlanetDetails(context.Background(), int(char.ID), planetID, char.AccessToken)
planetDetail, err := rh.ESI.GetPlanetPI(context.Background(), int(char.ID), int64(planetID), char.AccessToken)
if err != nil {
logger.Error("Failed to fetch planet details for character %s, planet %d: %v", charNameStr, planetID, err)
ctx.SetStatusCode(fasthttp.StatusInternalServerError)
@@ -197,12 +197,12 @@ func (rh *RouteHandler) handlePlanetsFull(ctx *fasthttp.RequestCtx) {
// Fetch details for each planet
type PlanetWithDetails struct {
Planet esi.Planet
Details *esi.PlanetDetail
Details *esi.PlanetPI
}
var planetsWithDetails []PlanetWithDetails
for _, planet := range planets {
details, err := rh.ESI.GetPlanetDetails(context.Background(), int(char.ID), planet.PlanetID, char.AccessToken)
details, err := rh.ESI.GetPlanetPI(context.Background(), int(char.ID), planet.PlanetID, char.AccessToken)
if err != nil {
logger.Warning("Failed to fetch details for planet %d: %v", planet.PlanetID, err)
// Continue with other planets even if one fails
@@ -237,8 +237,21 @@ func (rh *RouteHandler) handleGetExtractors(ctx *fasthttp.RequestCtx) {
return
}
planets, err := rh.ESI.GetCharacterPlanets(context.Background(), int(char.ID), char.AccessToken)
if err != nil {
logger.Error("Failed to get planets for character %s: %v", characterName, err)
ctx.SetStatusCode(fasthttp.StatusInternalServerError)
ctx.SetBodyString("Failed to get planets")
return
}
planetIds := make([]int64, len(planets))
for i, planet := range planets {
planetIds[i] = planet.PlanetID
}
// Get extractors using the standalone function
extractors, err := GetExtractorsForCharacter(rh.ESI, int(char.ID), char.AccessToken)
extractors, err := GetExtractorsForCharacter(rh.ESI, int(char.ID), char.AccessToken, planetIds)
if err != nil {
logger.Error("Failed to get extractors for character %s: %v", characterName, err)
ctx.SetStatusCode(fasthttp.StatusInternalServerError)