Add motherfucking logs..............................
This commit is contained in:
@@ -28,41 +28,52 @@ type StorageInfo struct {
|
||||
|
||||
// GetExtractorsForCharacter retrieves extractor information for a character
|
||||
func GetExtractorsForCharacter(esiClient esi.ESIInterface, characterID int, accessToken string) ([]ExtractorInfo, error) {
|
||||
logger.Debug("Getting extractors for character ID %d", characterID)
|
||||
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("Failed to get planets for character %d: %v", characterID, err)
|
||||
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)
|
||||
|
||||
var extractors []ExtractorInfo
|
||||
|
||||
for _, planet := range planets {
|
||||
for i, planet := range planets {
|
||||
logger.Info("GetExtractorsForCharacter: 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)
|
||||
if err != nil {
|
||||
logger.Warning("Failed to fetch details for planet %d: %v", planet.PlanetID, err)
|
||||
logger.Warning("GetExtractorsForCharacter: Failed to fetch details for planet %d: %v", planet.PlanetID, err)
|
||||
continue
|
||||
}
|
||||
logger.Info("GetExtractorsForCharacter: Got planet details for planet %d with %d pins", planet.PlanetID, len(details.Pins))
|
||||
|
||||
if details != nil {
|
||||
// Get planet name from universe endpoint
|
||||
planetNameData, err := esiClient.GetPlanetName(context.Background(), planet.PlanetID)
|
||||
if err != nil {
|
||||
logger.Error("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", planet.PlanetID, err)
|
||||
continue
|
||||
}
|
||||
logger.Info("GetExtractorsForCharacter: Planet %d name: %s", planet.PlanetID, planetNameData.Name)
|
||||
|
||||
// Count extractors and get expiry dates
|
||||
extractorCount := 0
|
||||
for _, pin := range details.Pins {
|
||||
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")
|
||||
}
|
||||
|
||||
extractors = append(extractors, ExtractorInfo{
|
||||
@@ -70,80 +81,105 @@ func GetExtractorsForCharacter(esiClient esi.ESIInterface, characterID int, acce
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
logger.Info("GetExtractorsForCharacter: Returning %d total extractors for character %d", len(extractors), characterID)
|
||||
return extractors, nil
|
||||
}
|
||||
|
||||
// GetStorageForCharacter retrieves storage information for a character
|
||||
func GetStorageForCharacter(esiClient esi.ESIInterface, characterID int, accessToken string) ([]StorageInfo, error) {
|
||||
logger.Debug("Getting storage for character ID %d", characterID)
|
||||
logger.Info("GetStorageForCharacter: Starting for character ID %d", characterID)
|
||||
|
||||
// Get character planets
|
||||
planets, err := esiClient.GetCharacterPlanets(context.Background(), characterID, accessToken)
|
||||
if err != nil {
|
||||
logger.Error("Failed to get planets for character %d: %v", characterID, err)
|
||||
logger.Error("GetStorageForCharacter: Failed to get planets for character %d: %v", characterID, err)
|
||||
return nil, err
|
||||
}
|
||||
logger.Info("GetStorageForCharacter: Found %d planets for character %d", len(planets), characterID)
|
||||
|
||||
var storage []StorageInfo
|
||||
|
||||
for _, planet := range planets {
|
||||
for i, planet := range planets {
|
||||
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)
|
||||
if err != nil {
|
||||
logger.Warning("Failed to fetch details for planet %d: %v", planet.PlanetID, err)
|
||||
logger.Warning("GetStorageForCharacter: Failed to fetch details for planet %d: %v", planet.PlanetID, err)
|
||||
continue
|
||||
}
|
||||
logger.Info("GetStorageForCharacter: Got planet details for planet %d with %d pins", planet.PlanetID, len(details.Pins))
|
||||
|
||||
if details != nil {
|
||||
// Get planet name from universe endpoint
|
||||
planetNameData, err := esiClient.GetPlanetName(context.Background(), planet.PlanetID)
|
||||
if err != nil {
|
||||
logger.Error("Failed to get planet name for planet ID %d: %v", planet.PlanetID, err)
|
||||
logger.Error("GetStorageForCharacter: Failed to get planet name for planet ID %d: %v", planet.PlanetID, err)
|
||||
continue
|
||||
}
|
||||
logger.Info("GetStorageForCharacter: Planet %d name: %s", planet.PlanetID, planetNameData.Name)
|
||||
|
||||
// Analyze storage utilization
|
||||
for _, pin := range details.Pins {
|
||||
storageCount := 0
|
||||
for j, pin := range details.Pins {
|
||||
logger.Info("GetStorageForCharacter: Processing pin %d/%d (TypeID: %d) on planet %s", j+1, len(details.Pins), pin.TypeID, planetNameData.Name)
|
||||
|
||||
// Check if this pin is actually a storage facility
|
||||
_, isStorage := constants.StorageCapacities[pin.TypeID]
|
||||
if !isStorage {
|
||||
// Skip non-storage facilities (like industry facilities)
|
||||
logger.Info("GetStorageForCharacter: Pin %d is not a storage facility (TypeID: %d), skipping", j+1, pin.TypeID)
|
||||
continue
|
||||
}
|
||||
|
||||
totalVolume := 0.0
|
||||
for _, content := range pin.Contents {
|
||||
volume, exists := constants.PIProductVolumes[content.TypeID]
|
||||
if !exists {
|
||||
logger.Error("Missing product volume data for type ID %d - cannot calculate storage utilization", content.TypeID)
|
||||
return nil, fmt.Errorf("missing product volume data for type ID %d", content.TypeID)
|
||||
}
|
||||
totalVolume += float64(content.Amount) * volume
|
||||
}
|
||||
logger.Info("GetStorageForCharacter: Pin %d is a storage facility (TypeID: %d)", j+1, pin.TypeID)
|
||||
|
||||
storageType, exists := constants.PI_TYPES_MAP[pin.TypeID]
|
||||
if !exists {
|
||||
logger.Error("Unknown storage type ID %d for planet %s - this should not happen", pin.TypeID, planetNameData.Name)
|
||||
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)
|
||||
}
|
||||
logger.Info("GetStorageForCharacter: Storage type: %s", storageType)
|
||||
|
||||
totalVolume := 0.0
|
||||
logger.Info("GetStorageForCharacter: Processing %d contents for storage facility %s", len(pin.Contents), storageType)
|
||||
for k, content := range pin.Contents {
|
||||
logger.Info("GetStorageForCharacter: Processing content %d/%d (TypeID: %d, Amount: %d)", k+1, len(pin.Contents), content.TypeID, content.Amount)
|
||||
|
||||
volume, exists := constants.PIProductVolumes[content.TypeID]
|
||||
if !exists {
|
||||
logger.Error("GetStorageForCharacter: Missing product volume data for type ID %d - cannot calculate storage utilization", content.TypeID)
|
||||
return nil, fmt.Errorf("missing product volume data for type ID %d", content.TypeID)
|
||||
}
|
||||
itemVolume := float64(content.Amount) * volume
|
||||
totalVolume += itemVolume
|
||||
logger.Info("GetStorageForCharacter: Content TypeID %d: Amount %d, Volume %f, ItemVolume %f", content.TypeID, content.Amount, volume, itemVolume)
|
||||
}
|
||||
|
||||
storageCapacity := constants.StorageCapacities[pin.TypeID]
|
||||
utilization := (totalVolume / float64(storageCapacity)) * 100.0
|
||||
logger.Info("GetStorageForCharacter: Storage calculation: %s on %s - TotalVolume: %f, Capacity: %d, Utilization: %f%%", storageType, planetNameData.Name, totalVolume, storageCapacity, utilization)
|
||||
|
||||
storage = append(storage, StorageInfo{
|
||||
PlanetName: planetNameData.Name,
|
||||
StorageType: storageType,
|
||||
Utilization: utilization,
|
||||
})
|
||||
storageCount++
|
||||
logger.Info("GetStorageForCharacter: Added storage facility %d to results", storageCount)
|
||||
}
|
||||
logger.Info("GetStorageForCharacter: Found %d storage facilities on planet %s", storageCount, planetNameData.Name)
|
||||
}
|
||||
}
|
||||
|
||||
logger.Info("GetStorageForCharacter: Returning %d total storage facilities for character %d", len(storage), characterID)
|
||||
return storage, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user