$name) { if (str_ends_with($name, "Blueprint")) { $blueprint_ids[] = $id; } } usleep(250000); } return $blueprint_ids; } // Batch fetch type names using /universe/names/ // Populate the blueprint cache function populate_blueprint_cache() { echo "Fetching all type IDs...\n"; $all_type_ids = get_all_type_ids(); if (empty($all_type_ids)) { echo "No type IDs retrieved.\n"; return; } echo "Filtering blueprint IDs...\n"; $blueprint_ids = filter_blueprint_ids($all_type_ids); if (empty($blueprint_ids)) { echo "No blueprint IDs found.\n"; return; } echo "Fetching blueprint names...\n"; $cached_data = []; $chunks = array_chunk($blueprint_ids, 1000); foreach ($chunks as $chunk) { $batch_names = fetch_type_names($chunk); foreach ($batch_names as $id => $name) { $cached_data[$id] = $name; } usleep(250000); } // Save to JSON cache file $cache_dir = __DIR__ . "/cache"; if (!is_dir($cache_dir)) { mkdir($cache_dir, 0775, true); } $cache_file = $cache_dir . "/blueprint_cache.json"; file_put_contents( $cache_file, json_encode($cached_data, JSON_PRETTY_PRINT) ); echo "Cache populated with " . count($cached_data) . " blueprint names.\n"; } // Run it populate_blueprint_cache();