Wire everything up
This commit is contained in:
@@ -27,65 +27,59 @@ type StorageInfo struct {
|
||||
}
|
||||
|
||||
// GetExtractorsForCharacter retrieves extractor information for a character
|
||||
func GetExtractorsForCharacter(esiClient esi.ESIInterface, characterID int, accessToken string) ([]ExtractorInfo, error) {
|
||||
func GetExtractorsForCharacter(esiClient esi.ESIInterface, characterID int, accessToken string, planetIDs []int64) ([]ExtractorInfo, error) {
|
||||
logger.Info("GetExtractorsForCharacter: Starting for character ID %d", characterID)
|
||||
|
||||
// Get character planets
|
||||
planets, err := esiClient.GetCharacterPlanets(context.Background(), characterID, accessToken)
|
||||
if err != nil {
|
||||
logger.Error("GetExtractorsForCharacter: Failed to get planets for character %d: %v", characterID, err)
|
||||
return nil, err
|
||||
}
|
||||
logger.Info("GetExtractorsForCharacter: Found %d planets for character %d", len(planets), characterID)
|
||||
logger.Info("GetExtractorsForCharacter: Found %d planets for character %d", len(planetIDs), characterID)
|
||||
|
||||
var extractors []ExtractorInfo
|
||||
|
||||
for i, planet := range planets {
|
||||
logger.Info("GetExtractorsForCharacter: Processing planet %d/%d (ID: %d)", i+1, len(planets), planet.PlanetID)
|
||||
for i, planetID := range planetIDs {
|
||||
logger.Info("GetExtractorsForCharacter: Processing planet %d/%d (ID: %d)", i+1, len(planetIDs), planetID)
|
||||
|
||||
// Get planet details
|
||||
details, err := esiClient.GetPlanetDetails(context.Background(), characterID, planet.PlanetID, accessToken)
|
||||
details, err := esiClient.GetPlanetPI(context.Background(), characterID, planetID, accessToken)
|
||||
if err != nil {
|
||||
logger.Warning("GetExtractorsForCharacter: Failed to fetch details for planet %d: %v", planet.PlanetID, err)
|
||||
logger.Warning("GetExtractorsForCharacter: Failed to fetch details for planet %d: %v", planetID, err)
|
||||
continue
|
||||
}
|
||||
logger.Info("GetExtractorsForCharacter: Got planet details for planet %d with %d pins", planet.PlanetID, len(details.Pins))
|
||||
logger.Info("GetExtractorsForCharacter: Got planet details for planet %d with %d pins", planetID, len(details.Pins))
|
||||
|
||||
if details != nil {
|
||||
// Get planet name from universe endpoint
|
||||
planetNameData, err := esiClient.GetPlanetName(context.Background(), planet.PlanetID)
|
||||
planetNameData, err := esiClient.GetPlanetName(context.Background(), planetID)
|
||||
if err != nil {
|
||||
logger.Error("GetExtractorsForCharacter: Failed to get planet name for planet ID %d: %v", planet.PlanetID, err)
|
||||
logger.Error("GetExtractorsForCharacter: Failed to get planet name for planet ID %d: %v", planetID, err)
|
||||
continue
|
||||
}
|
||||
logger.Info("GetExtractorsForCharacter: Planet %d name: %s", planet.PlanetID, planetNameData.Name)
|
||||
logger.Info("GetExtractorsForCharacter: Planet %d name: %s", planetID, planetNameData.Name)
|
||||
|
||||
// Count extractors and get expiry dates
|
||||
extractorCount := 0
|
||||
for j, pin := range details.Pins {
|
||||
logger.Info("GetExtractorsForCharacter: Processing pin %d/%d (TypeID: %d) on planet %s", j+1, len(details.Pins), pin.TypeID, planetNameData.Name)
|
||||
// for j, pin := range details.Pins {
|
||||
// logger.Info("GetExtractorsForCharacter: Processing pin %d/%d (TypeID: %d) on planet %s", j+1, len(details.Pins), pin.TypeID, planetNameData.Name)
|
||||
|
||||
if pin.ExtractorDetails != nil {
|
||||
logger.Info("GetExtractorsForCharacter: Found extractor (TypeID: %d) on planet %s", pin.TypeID, planetNameData.Name)
|
||||
extractorCount++
|
||||
expiryDate := "N/A"
|
||||
if pin.ExpiryTime != nil {
|
||||
expiryDate = *pin.ExpiryTime
|
||||
logger.Info("GetExtractorsForCharacter: Extractor expiry: %s", expiryDate)
|
||||
} else {
|
||||
logger.Info("GetExtractorsForCharacter: Extractor has no expiry time")
|
||||
}
|
||||
// if pin.ExtractorDetails != nil {
|
||||
// logger.Info("GetExtractorsForCharacter: Found extractor (TypeID: %d) on planet %s", pin.TypeID, planetNameData.Name)
|
||||
// extractorCount++
|
||||
// expiryDate := "N/A"
|
||||
// if pin.ExpiryTime != nil {
|
||||
// expiryDate = *pin.ExpiryTime
|
||||
// logger.Info("GetExtractorsForCharacter: Extractor expiry: %s", expiryDate)
|
||||
// } else {
|
||||
// logger.Info("GetExtractorsForCharacter: Extractor has no expiry time")
|
||||
// }
|
||||
|
||||
extractors = append(extractors, ExtractorInfo{
|
||||
PlanetName: planetNameData.Name,
|
||||
ExtractorNumber: extractorCount,
|
||||
ExpiryDate: expiryDate,
|
||||
})
|
||||
logger.Info("GetExtractorsForCharacter: Added extractor %d to results", extractorCount)
|
||||
} else {
|
||||
logger.Info("GetExtractorsForCharacter: Pin %d is not an extractor (TypeID: %d)", j+1, pin.TypeID)
|
||||
}
|
||||
}
|
||||
// extractors = append(extractors, ExtractorInfo{
|
||||
// PlanetName: planetNameData.Name,
|
||||
// ExtractorNumber: extractorCount,
|
||||
// ExpiryDate: expiryDate,
|
||||
// })
|
||||
// logger.Info("GetExtractorsForCharacter: Added extractor %d to results", extractorCount)
|
||||
// } else {
|
||||
// logger.Info("GetExtractorsForCharacter: Pin %d is not an extractor (TypeID: %d)", j+1, pin.TypeID)
|
||||
// }
|
||||
// }
|
||||
logger.Info("GetExtractorsForCharacter: Found %d extractors on planet %s", extractorCount, planetNameData.Name)
|
||||
}
|
||||
}
|
||||
@@ -112,7 +106,7 @@ func GetStorageForCharacter(esiClient esi.ESIInterface, characterID int, accessT
|
||||
logger.Info("GetStorageForCharacter: Processing planet %d/%d (ID: %d)", i+1, len(planets), planet.PlanetID)
|
||||
|
||||
// Get planet details
|
||||
details, err := esiClient.GetPlanetDetails(context.Background(), characterID, planet.PlanetID, accessToken)
|
||||
details, err := esiClient.GetPlanetPI(context.Background(), characterID, planet.PlanetID, accessToken)
|
||||
if err != nil {
|
||||
logger.Warning("GetStorageForCharacter: Failed to fetch details for planet %d: %v", planet.PlanetID, err)
|
||||
continue
|
||||
@@ -141,7 +135,7 @@ func GetStorageForCharacter(esiClient esi.ESIInterface, characterID int, accessT
|
||||
}
|
||||
logger.Info("GetStorageForCharacter: Pin %d is a storage facility (TypeID: %d)", j+1, pin.TypeID)
|
||||
|
||||
storageType, exists := constants.PI_TYPES_MAP[pin.TypeID]
|
||||
storageType, exists := constants.PITypesMap[pin.TypeID]
|
||||
if !exists {
|
||||
logger.Error("GetStorageForCharacter: Unknown storage type ID %d for planet %s - this should not happen", pin.TypeID, planetNameData.Name)
|
||||
return nil, fmt.Errorf("unknown storage type ID %d", pin.TypeID)
|
||||
|
||||
Reference in New Issue
Block a user