From 882b9eddfc923064c20513826325b7f57dde7e9d Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Fri, 10 Oct 2025 23:42:03 +0200 Subject: [PATCH] Fix storage utilization computing --- constants/storage.go | 445 +++++++++++++++++++++++++++++++++++++++++++ orchestrator.go | 2 +- routes/data.go | 58 +++--- 3 files changed, 477 insertions(+), 28 deletions(-) create mode 100644 constants/storage.go diff --git a/constants/storage.go b/constants/storage.go new file mode 100644 index 0000000..24741b1 --- /dev/null +++ b/constants/storage.go @@ -0,0 +1,445 @@ +package constants + +var PI_TYPES_MAP = map[int]string{ + 44: "Enriched Uranium", + 2073: "Microorganisms", + 2256: "Temperate Launchpad", + 2257: "Ice Storage Facility", + 2267: "Base Metals", + 2268: "Aqueous Liquids", + 2270: "Noble Metals", + 2272: "Heavy Metals", + 2286: "Planktic Colonies", + 2287: "Complex Organisms", + 2288: "Carbon Compounds", + 2305: "Autotrophs", + 2306: "Non-CS Crystals", + 2307: "Felsic Magma", + 2308: "Suspended Plasma", + 2309: "Ionic Solutions", + 2310: "Noble Gas", + 2311: "Reactive Gas", + 2312: "Supertensile Plastics", + 2317: "Oxides", + 2319: "Test Cultures", + 2321: "Polyaramids", + 2327: "Microfiber Shielding", + 2328: "Water-Cooled CPU", + 2329: "Biocells", + 2344: "Condensates", + 2345: "Camera Drones", + 2346: "Synthetic Synapses", + 2348: "Gel-Matrix Biopaste", + 2349: "Supercomputers", + 2351: "Smartfab Units", + 2352: "Nuclear Reactors", + 2354: "Neocoms", + 2358: "Biotech Research Reports", + 2360: "Industrial Explosives", + 2361: "Hermetic Membranes", + 2366: "Hazmat Detection Systems", + 2367: "Cryoprotectant Solution", + 2389: "Plasmoids", + 2390: "Electrolytes", + 2392: "Oxidizing Compound", + 2393: "Bacteria", + 2395: "Proteins", + 2396: "Biofuels", + 2397: "Industrial Fibers", + 2398: "Reactive Metals", + 2399: "Precious Metals", + 2400: "Toxic Metals", + 2401: "Chiral Structures", + 2463: "Nanites", + 2469: "Lava Basic Industry Facility", + 2470: "Lava Advanced Industry Facility", + 2471: "Plasma Basic Industry Facility", + 2472: "Plasma Advanced Industry Facility", + 2473: "Barren Basic Industry Facility", + 2474: "Barren Advanced Industry Facility", + 2475: "Barren High-Tech Production Plant", + 2480: "Temperate Advanced Industry Facility", + 2481: "Temperate Basic Industry Facility", + 2482: "Temperate High-Tech Production Plant", + 2483: "Storm Basic Industry Facility", + 2484: "Storm Advanced Industry Facility", + 2485: "Oceanic Advanced Industry Facility", + 2490: "Oceanic Basic Industry Facility", + 2491: "Ice Advanced Industry Facility", + 2492: "Gas Basic Industry Facility", + 2493: "Ice Basic Industry Facility", + 2494: "Gas Advanced Industry Facility", + 2535: "Oceanic Storage Facility", + 2536: "Gas Storage Facility", + 2541: "Barren Storage Facility", + 2542: "Oceanic Launchpad", + 2543: "Gas Launchpad", + 2544: "Barren Launchpad", + 2552: "Ice Launchpad", + 2555: "Lava Launchpad", + 2556: "Plasma Launchpad", + 2557: "Storm Launchpad", + 2558: "Lava Storage Facility", + 2560: "Plasma Storage Facility", + 2561: "Storm Storage Facility", + 2562: "Temperate Storage Facility", + 2848: "Barren Extractor Control Unit", + 2867: "Broadcast Node", + 2868: "Integrity Response Drones", + 2869: "Nano-Factory", + 2870: "Organic Mortar Applicators", + 2871: "Recursive Computing Module", + 2872: "Self-Harmonizing Power Core", + 2875: "Sterile Conduits", + 2876: "Wetware Mainframe", + 3060: "Gas Extractor Control Unit", + 3061: "Ice Extractor Control Unit", + 3062: "Lava Extractor Control Unit", + 3063: "Oceanic Extractor Control Unit", + 3064: "Plasma Extractor Control Unit", + 3067: "Storm Extractor Control Unit", + 3068: "Temperate Extractor Control Unit", + 3645: "Water", + 3683: "Oxygen", + 3689: "Mechanical Parts", + 3691: "Synthetic Oil", + 3693: "Fertilizer", + 3695: "Polytextiles", + 3697: "Silicate Glass", + 3725: "Livestock", + 3775: "Viral Agent", + 3779: "Biomass", + 3828: "Construction Blocks", + 9828: "Silicon", + 9830: "Rocket Fuel", + 9832: "Coolant", + 9834: "Guidance Systems", + 9836: "Consumer Electronics", + 9838: "Superconductors", + 9840: "Transmitter", + 9842: "Miniature Electronics", + 9846: "Planetary Vehicles", + 9848: "Robotics", + 12836: "Transcranial Microcontrollers", + 15317: "Genetically Enhanced Livestock", + 17136: "Ukomi Superconductors", + 17392: "Data Chips", + 17898: "High-Tech Transmitters", + 28974: "Vaccines", + } + +var PITypes = map[int]string{ + 2469: "Lava Basic Industry Facility", + 2470: "Lava Advanced Industry Facility", + 2471: "Plasma Basic Industry Facility", + 2472: "Plasma Advanced Industry Facility", + 2473: "Barren Basic Industry Facility", + 2474: "Barren Advanced Industry Facility", + 2475: "Barren High-Tech Production Plant", + 2480: "Temperate Advanced Industry Facility", + 2481: "Temperate Basic Industry Facility", + 2482: "Temperate High-Tech Production Plant", + 2483: "Storm Basic Industry Facility", + 2484: "Storm Advanced Industry Facility", + 2485: "Oceanic Advanced Industry Facility", + 2490: "Oceanic Basic Industry Facility", + 2491: "Ice Advanced Industry Facility", + 2492: "Gas Basic Industry Facility", + 2493: "Ice Basic Industry Facility", + 2494: "Gas Advanced Industry Facility", + 2848: "Barren Extractor Control Unit", + 3060: "Gas Extractor Control Unit", + 3061: "Ice Extractor Control Unit", + 3062: "Lava Extractor Control Unit", + 3063: "Oceanic Extractor Control Unit", + 3064: "Plasma Extractor Control Unit", + 3067: "Storm Extractor Control Unit", + 3068: "Temperate Extractor Control Unit", + 2257: "Ice Storage Facility", + 2535: "Oceanic Storage Facility", + 2536: "Gas Storage Facility", + 2541: "Barren Storage Facility", + 2558: "Lava Storage Facility", + 2560: "Plasma Storage Facility", + 2561: "Storm Storage Facility", + 2562: "Temperate Storage Facility", + 2256: "Temperate Launchpad", + 2542: "Oceanic Launchpad", + 2543: "Gas Launchpad", + 2544: "Barren Launchpad", + 2552: "Ice Launchpad", + 2555: "Lava Launchpad", + 2556: "Plasma Launchpad", + 2557: "Storm Launchpad", + 2267: "Base Metals", + 2270: "Noble Metals", + 2272: "Heavy Metals", + 2306: "Non-CS Crystals", + 2307: "Felsic Magma", + 2268: "Aqueous Liquids", + 2308: "Suspended Plasma", + 2309: "Ionic Solutions", + 2310: "Noble Gas", + 2311: "Reactive Gas", + 44: "Enriched Uranium", + 2312: "Supertensile Plastics", + 2317: "Oxides", + 2319: "Test Cultures", + 2321: "Polyaramids", + 2327: "Microfiber Shielding", + 2328: "Water-Cooled CPU", + 2329: "Biocells", + 2463: "Nanites", + 3689: "Mechanical Parts", + 3691: "Synthetic Oil", + 3693: "Fertilizer", + 3695: "Polytextiles", + 3697: "Silicate Glass", + 3725: "Livestock", + 3775: "Viral Agent", + 3828: "Construction Blocks", + 9830: "Rocket Fuel", + 9832: "Coolant", + 9836: "Consumer Electronics", + 9838: "Superconductors", + 9840: "Transmitter", + 9842: "Miniature Electronics", + 15317: "Genetically Enhanced Livestock", + 2073: "Microorganisms", + 2286: "Planktic Colonies", + 2287: "Complex Organisms", + 2288: "Carbon Compounds", + 2305: "Autotrophs", + 2344: "Condensates", + 2345: "Camera Drones", + 2346: "Synthetic Synapses", + 2348: "Gel-Matrix Biopaste", + 2349: "Supercomputers", + 2351: "Smartfab Units", + 2352: "Nuclear Reactors", + 2354: "Neocoms", + 2358: "Biotech Research Reports", + 2360: "Industrial Explosives", + 2361: "Hermetic Membranes", + 2366: "Hazmat Detection Systems", + 2367: "Cryoprotectant Solution", + 9834: "Guidance Systems", + 9846: "Planetary Vehicles", + 9848: "Robotics", + 12836: "Transcranial Microcontrollers", + 17136: "Ukomi Superconductors", + 17392: "Data Chips", + 17898: "High-Tech Transmitters", + 28974: "Vaccines", + 2867: "Broadcast Node", + 2868: "Integrity Response Drones", + 2869: "Nano-Factory", + 2870: "Organic Mortar Applicators", + 2871: "Recursive Computing Module", + 2872: "Self-Harmonizing Power Core", + 2875: "Sterile Conduits", + 2876: "Wetware Mainframe", + 2389: "Plasmoids", + 2390: "Electrolytes", + 2392: "Oxidizing Compound", + 2393: "Bacteria", + 2395: "Proteins", + 2396: "Biofuels", + 2397: "Industrial Fibers", + 2398: "Reactive Metals", + 2399: "Precious Metals", + 2400: "Toxic Metals", + 2401: "Chiral Structures", + 3645: "Water", + 3683: "Oxygen", + 3779: "Biomass", + 9828: "Silicon", +} + +var StorageIDs = []int{ + 2257, // Ice Storage Facility + 2535, // Oceanic Storage Facility + 2536, // Gas Storage Facility + 2541, // Barren Storage Facility + 2558, // Lava Storage Facility + 2560, // Plasma Storage Facility + 2561, // Storm Storage Facility + 2562, // Temperate Storage Facility + 2256, // Temperate Launchpad + 2542, // Oceanic Launchpad + 2543, // Gas Launchpad + 2544, // Barren Launchpad + 2552, // Ice Launchpad + 2555, // Lava Launchpad + 2556, // Plasma Launchpad + 2557, // Storm Launchpad +} + +var PIProductVolumes = map[int]float64{ + 44: 0.75, // Enriched Uranium + 2073: 0.005, // Microorganisms + 2256: 0.0, // Temperate Launchpad + 2257: 0.0, // Ice Storage Facility + 2267: 0.005, // Base Metals + 2268: 0.005, // Aqueous Liquids + 2270: 0.005, // Noble Metals + 2272: 0.005, // Heavy Metals + 2286: 0.005, // Planktic Colonies + 2287: 0.005, // Complex Organisms + 2288: 0.005, // Carbon Compounds + 2305: 0.005, // Autotrophs + 2306: 0.005, // Non-CS Crystals + 2307: 0.005, // Felsic Magma + 2308: 0.005, // Suspended Plasma + 2309: 0.005, // Ionic Solutions + 2310: 0.005, // Noble Gas + 2311: 0.005, // Reactive Gas + 2312: 0.75, // Supertensile Plastics + 2317: 0.75, // Oxides + 2319: 0.75, // Test Cultures + 2321: 0.75, // Polyaramids + 2327: 0.75, // Microfiber Shielding + 2328: 0.75, // Water-Cooled CPU + 2329: 0.75, // Biocells + 2344: 3.0, // Condensates + 2345: 3.0, // Camera Drones + 2346: 3.0, // Synthetic Synapses + 2348: 3.0, // Gel-Matrix Biopaste + 2349: 3.0, // Supercomputers + 2351: 3.0, // Smartfab Units + 2352: 3.0, // Nuclear Reactors + 2354: 3.0, // Neocoms + 2358: 3.0, // Biotech Research Reports + 2360: 3.0, // Industrial Explosives + 2361: 3.0, // Hermetic Membranes + 2366: 3.0, // Hazmat Detection Systems + 2367: 3.0, // Cryoprotectant Solution + 2389: 0.19, // Plasmoids + 2390: 0.19, // Electrolytes + 2392: 0.19, // Oxidizing Compound + 2393: 0.19, // Bacteria + 2395: 0.19, // Proteins + 2396: 0.19, // Biofuels + 2397: 0.19, // Industrial Fibers + 2398: 0.19, // Reactive Metals + 2399: 0.19, // Precious Metals + 2400: 0.19, // Toxic Metals + 2401: 0.19, // Chiral Structures + 2463: 0.75, // Nanites + 2469: 0.0, // Lava Basic Industry Facility + 2470: 0.0, // Lava Advanced Industry Facility + 2471: 0.0, // Plasma Basic Industry Facility + 2472: 0.0, // Plasma Advanced Industry Facility + 2473: 0.0, // Barren Basic Industry Facility + 2474: 0.0, // Barren Advanced Industry Facility + 2475: 0.0, // Barren High-Tech Production Plant + 2480: 0.0, // Temperate Advanced Industry Facility + 2481: 0.0, // Temperate Basic Industry Facility + 2482: 0.0, // Temperate High-Tech Production Plant + 2483: 0.0, // Storm Basic Industry Facility + 2484: 0.0, // Storm Advanced Industry Facility + 2485: 0.0, // Oceanic Advanced Industry Facility + 2490: 0.0, // Oceanic Basic Industry Facility + 2491: 0.0, // Ice Advanced Industry Facility + 2492: 0.0, // Gas Basic Industry Facility + 2493: 0.0, // Ice Basic Industry Facility + 2494: 0.0, // Gas Advanced Industry Facility + 2535: 0.0, // Oceanic Storage Facility + 2536: 0.0, // Gas Storage Facility + 2541: 0.0, // Barren Storage Facility + 2542: 0.0, // Oceanic Launchpad + 2543: 0.0, // Gas Launchpad + 2544: 0.0, // Barren Launchpad + 2552: 0.0, // Ice Launchpad + 2555: 0.0, // Lava Launchpad + 2556: 0.0, // Plasma Launchpad + 2557: 0.0, // Storm Launchpad + 2558: 0.0, // Lava Storage Facility + 2560: 0.0, // Plasma Storage Facility + 2561: 0.0, // Storm Storage Facility + 2562: 0.0, // Temperate Storage Facility + 2848: 0.0, // Barren Extractor Control Unit + 2867: 50.0, // Broadcast Node + 2868: 50.0, // Integrity Response Drones + 2869: 50.0, // Nano-Factory + 2870: 50.0, // Organic Mortar Applicators + 2871: 50.0, // Recursive Computing Module + 2872: 50.0, // Self-Harmonizing Power Core + 2875: 50.0, // Sterile Conduits + 2876: 50.0, // Wetware Mainframe + 3060: 0.0, // Gas Extractor Control Unit + 3061: 0.0, // Ice Extractor Control Unit + 3062: 0.0, // Lava Extractor Control Unit + 3063: 0.0, // Oceanic Extractor Control Unit + 3064: 0.0, // Plasma Extractor Control Unit + 3067: 0.0, // Storm Extractor Control Unit + 3068: 0.0, // Temperate Extractor Control Unit + 3645: 0.19, // Water + 3683: 0.19, // Oxygen + 3689: 0.75, // Mechanical Parts + 3691: 0.75, // Synthetic Oil + 3693: 0.75, // Fertilizer + 3695: 0.75, // Polytextiles + 3697: 0.75, // Silicate Glass + 3725: 0.75, // Livestock + 3775: 0.75, // Viral Agent + 3779: 0.19, // Biomass + 3828: 0.75, // Construction Blocks + 9828: 0.19, // Silicon + 9830: 0.75, // Rocket Fuel + 9832: 0.75, // Coolant + 9834: 3.0, // Guidance Systems + 9836: 0.75, // Consumer Electronics + 9838: 0.75, // Superconductors + 9840: 0.75, // Transmitter + 9842: 0.75, // Miniature Electronics + 9846: 3.0, // Planetary Vehicles + 9848: 3.0, // Robotics + 12836: 3.0, // Transcranial Microcontrollers + 15317: 0.75, // Genetically Enhanced Livestock + 17136: 3.0, // Ukomi Superconductors + 17392: 3.0, // Data Chips + 17898: 3.0, // High-Tech Transmitters + 28974: 3.0, // Vaccines +} + +var StorageCapacities = map[int]int{ + 2257: 12000, // Ice Storage Facility + 2535: 12000, // Oceanic Storage Facility + 2536: 12000, // Gas Storage Facility + 2541: 12000, // Barren Storage Facility + 2558: 12000, // Lava Storage Facility + 2560: 12000, // Plasma Storage Facility + 2561: 12000, // Storm Storage Facility + 2562: 12000, // Temperate Storage Facility + 2256: 10000, // Temperate Launchpad + 2542: 10000, // Oceanic Launchpad + 2543: 10000, // Gas Launchpad + 2544: 10000, // Barren Launchpad + 2552: 10000, // Ice Launchpad + 2555: 10000, // Lava Launchpad + 2556: 10000, // Plasma Launchpad + 2557: 10000, // Storm Launchpad +} + +var LaunchpadIDs = map[int]struct{}{ + 2256: {}, + 2542: {}, + 2543: {}, + 2544: {}, + 2552: {}, + 2555: {}, + 2556: {}, + 2557: {}, +} + +var ExtractorTypeIDs = map[int]struct{}{ + 2848: {}, + 3060: {}, + 3061: {}, + 3062: {}, + 3063: {}, + 3064: {}, + 3067: {}, + 3068: {}, +} \ No newline at end of file diff --git a/orchestrator.go b/orchestrator.go index 4afe392..af11732 100644 --- a/orchestrator.go +++ b/orchestrator.go @@ -153,7 +153,7 @@ func (o *Orchestrator) updateExpiryTimers(characterName string, extractors []rou continue } - expiryTime, err := time.Parse("2006-01-02 15:04:05", extractor.ExpiryDate) + expiryTime, err := time.Parse(time.RFC3339, extractor.ExpiryDate) if err != nil { logger.Warning("Failed to parse expiry date %s for character %s: %v", extractor.ExpiryDate, characterName, err) continue diff --git a/routes/data.go b/routes/data.go index 2b0fc96..b6547c5 100644 --- a/routes/data.go +++ b/routes/data.go @@ -6,6 +6,7 @@ import ( "fmt" "time" + "go-eve-pi/constants" "go-eve-pi/esi" logger "git.site.quack-lab.dev/dave/cylogger" @@ -108,34 +109,37 @@ func GetStorageForCharacter(esiClient esi.ESIInterface, characterID int, accessT // Analyze storage utilization for _, pin := range details.Pins { - if len(pin.Contents) > 0 { - // Calculate utilization based on contents - totalAmount := 0 - for _, content := range pin.Contents { - totalAmount += content.Amount - } - - // Determine storage type based on pin type - storageType := "Unknown" - switch pin.TypeID { - case 2254, 2255, 2256: // Launch pads - storageType = "Launch Pad" - case 2524, 2525, 2526: // Storage facilities - storageType = "Storage" - } - - // Calculate utilization percentage (assuming max capacity of 10000) - utilization := float64(totalAmount) / 10000.0 * 100.0 - if utilization > 100.0 { - utilization = 100.0 - } - - storage = append(storage, StorageInfo{ - PlanetName: planetNameData.Name, - StorageType: storageType, - Utilization: utilization, - }) + // Check if this pin is actually a storage facility + _, isStorage := constants.StorageCapacities[pin.TypeID] + if !isStorage { + // Skip non-storage facilities (like industry facilities) + 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 + } + + 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) + return nil, fmt.Errorf("unknown storage type ID %d", pin.TypeID) + } + + storageCapacity := constants.StorageCapacities[pin.TypeID] + utilization := (totalVolume / float64(storageCapacity)) * 100.0 + + storage = append(storage, StorageInfo{ + PlanetName: planetNameData.Name, + StorageType: storageType, + Utilization: utilization, + }) } } }