From 8a98cfa7fc28ede9adf6754cf19da46db53a3a87 Mon Sep 17 00:00:00 2001 From: Jeroen Schweitzer Date: Sat, 4 Apr 2026 23:08:59 +0200 Subject: [PATCH] =?UTF-8?q?fix(simulation):=20Sprint=2030=20server=20?= =?UTF-8?q?=E2=80=94=20atmosphere=20filter=20fix=20+=20corridor-status=20c?= =?UTF-8?q?md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #762: Update habitable_planet_count filter to accept both "breathable" and "standard" atmosphere values via matches! macro. Previously only matched "breathable", causing all committed systems to report 0 habitable planets. #744: Add corridor-status subcommand to atlas CLI. Shows remaining unfinished systems grouped by geographic_sector and hop_distance, with plain text table output and totals. Cargo.lock updated for v0.1.29. Co-Authored-By: Claude Opus 4.6 --- server/Cargo.lock | 2 +- server/src/bin/atlas.rs | 69 +++++++++++++++++++++++++++++++++++++++-- 2 files changed, 68 insertions(+), 3 deletions(-) diff --git a/server/Cargo.lock b/server/Cargo.lock index b84e3f58e..b510e031b 100644 --- a/server/Cargo.lock +++ b/server/Cargo.lock @@ -1236,7 +1236,7 @@ dependencies = [ [[package]] name = "settled-reach-server" -version = "0.1.28" +version = "0.1.29" dependencies = [ "bevy_app", "bevy_ecs", diff --git a/server/src/bin/atlas.rs b/server/src/bin/atlas.rs index a5316d970..6157e3110 100644 --- a/server/src/bin/atlas.rs +++ b/server/src/bin/atlas.rs @@ -182,6 +182,8 @@ enum Commands { #[arg(long, default_value = "wiki/star-systems")] wiki: String, }, + /// Show remaining unfinished systems grouped by geographic sector and hop distance + CorridorStatus, } // --------------------------------------------------------------------------- @@ -1290,8 +1292,10 @@ fn cmd_commit_system(conn: &Connection, path: &str) { .bodies .iter() .filter(|b| { - b.atmosphere.as_deref() == Some("breathable") - && (b.body_type == "planet" || b.body_type == "moon") + matches!( + b.atmosphere.as_deref(), + Some("breathable") | Some("standard") + ) && (b.body_type == "planet" || b.body_type == "moon") }) .count() as i32; @@ -1992,6 +1996,66 @@ fn format_population(pop: i64) -> String { // cmd_populate removed — replaced by per-system author/commit workflow +fn cmd_corridor_status(conn: &Connection) { + // Query unfinished systems grouped by geographic_sector and hop_distance_from_gateway. + // "Unfinished" = no rows in bodies for this system_id. + let mut stmt = conn + .prepare( + "SELECT s.geographic_sector, g.hop_distance_from_gateway, COUNT(*) AS remaining + FROM star_systems s + JOIN system_gates g ON s.system_id = g.system_id + WHERE s.system_id NOT IN (SELECT DISTINCT system_id FROM bodies) + GROUP BY s.geographic_sector, g.hop_distance_from_gateway + ORDER BY s.geographic_sector, g.hop_distance_from_gateway", + ) + .unwrap(); + + struct Row { + sector: Option, + hop: Option, + remaining: i64, + } + + let rows: Vec = stmt + .query_map([], |row| { + Ok(Row { + sector: row.get(0)?, + hop: row.get(1)?, + remaining: row.get(2)?, + }) + }) + .unwrap() + .filter_map(|r| r.ok()) + .collect(); + + if rows.is_empty() { + println!("All systems have bodies authored."); + return; + } + + // Plain text table: corridor | hop | remaining + let total: i64 = rows.iter().map(|r| r.remaining).sum(); + println!("{:<30} {:>4} {:>9}", "Corridor", "Hop", "Remaining"); + println!("{}", "-".repeat(48)); + let mut last_sector = String::new(); + for row in &rows { + let sector = row.sector.as_deref().unwrap_or("(unknown)"); + let hop = row + .hop + .map(|h| h.to_string()) + .unwrap_or_else(|| "?".to_string()); + if sector != last_sector { + if !last_sector.is_empty() { + println!(); + } + last_sector = sector.to_string(); + } + println!("{:<30} {:>4} {:>9}", sector, hop, row.remaining); + } + println!("{}", "-".repeat(48)); + println!("{:<30} {:>4} {:>9}", "TOTAL", "", total); +} + // --------------------------------------------------------------------------- // Main // --------------------------------------------------------------------------- @@ -2039,5 +2103,6 @@ fn main() { Commands::Unfinished { sector } => cmd_unfinished(&conn, sector.as_deref()), Commands::Next { hop, sector } => cmd_next(&conn, *hop, sector.as_deref()), Commands::SyncWiki { system_id, wiki } => cmd_sync_wiki(&conn, system_id.as_deref(), wiki), + Commands::CorridorStatus => cmd_corridor_status(&conn), } }