refactor: modular architecture with unified error handling and DashMap concurrency
- Break monolithic records.rs into commands/, output/, parsing/ modules - Add lib.rs with shared types (AppError, Car, BestCarRecord, etc.) - Replace Arc<Mutex<HashMap>> with DashMap for concurrent access - Add unified AppError enum with thiserror - Add configurable CLI paths (--my-cars, --cars-db, --times-dir, --tracks-db) - Add serde deserialization for Car struct - Add CSV escaping for fields with commas/quotes/newlines - Fix track name splitting: split_once -> rsplit_once for _a handling - Add integration tests, proptest property-based tests, and unit tests - Add rustfmt.toml configuration - Update documentation (API, ARCHITECTURE, DATA_STRUCTURES, README)
This commit is contained in:
parent
9d57b18a4e
commit
a9a46ee551
24 changed files with 3541 additions and 1470 deletions
19
src/commands/best.rs
Normal file
19
src/commands/best.rs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
//! Best and very_best command implementations.
|
||||
//!
|
||||
//! Generates best.csv (all cars best on at least one track) and
|
||||
//! very_best.csv (cars best on >= min_count tracks).
|
||||
|
||||
use top_drives::AppError;
|
||||
|
||||
use crate::commands::{load_my_cars_or_warn, run_analysis};
|
||||
use crate::output::{write_best_csv, write_very_best_csv};
|
||||
|
||||
/// Executes the best command: generates best.csv and very_best.csv.
|
||||
pub async fn run_best(my_cars_path: &str, cars_db_path: &str, times_dir: &str, min_count: usize) -> Result<(), AppError> {
|
||||
let my_data = load_my_cars_or_warn(my_cars_path)?;
|
||||
let (_ctx, counts) = run_analysis(&my_data.owned, cars_db_path, times_dir).await?;
|
||||
write_best_csv(&counts)?;
|
||||
write_very_best_csv(&counts, min_count)?;
|
||||
println!("Written: best.csv, very_best.csv");
|
||||
Ok(())
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue