Fix multi-copy car handling: track all configs per guid and add copy count

- Change owned_configs from HashMap<String, String> to HashMap<String, Vec<String>>
  to capture all configs across copies (previously last-write-wins lost data)
- Add copy_count field to MyCarsData and CarCounts for wishlist copy-coverage logic
- Fix improve.csv to exclude already-owned final configs as targets (e.g., Fiat
  Campagnola 1974 now targets 332 instead of already-owned 323)
- Fix wishlist to check all owned configs for exact-match and final-build detection
- Fix trash to check all configs for final-build-not-best detection
- Update all tests for new Vec type and add multi-copy improve test
This commit is contained in:
Jan-Peter von Hunnius 2026-06-06 21:13:47 +02:00
parent b24b274d25
commit 62688926c3
7 changed files with 494 additions and 83 deletions

View file

@ -1,5 +1,6 @@
//! Property-based tests using proptest for sorting and comparison functions.
use std::collections::HashMap;
use proptest::prelude::*;
use top_drives::test_utils::{make_car, make_record};
@ -177,7 +178,7 @@ proptest! {
cars in proptest::collection::vec(car_strategy(), 0..20)
) {
let ctx = AnalysisContext::default();
let counts = compute_car_counts(&ctx, cars.clone(), empty_my_data());
let counts = compute_car_counts(&ctx, cars.clone(), empty_my_data(), HashMap::new());
// No best_cars entries → every car has 0 wins → by_rid is empty
assert_eq!(counts.by_rid.len(), 0);
// guid_to_rid is also empty since no car won any track
@ -212,7 +213,7 @@ proptest! {
}
let car_list = vec![make_car(&rid, rq, &guid)];
let counts = compute_car_counts(&ctx, car_list, empty_my_data());
let counts = compute_car_counts(&ctx, car_list, empty_my_data(), HashMap::new());
let entry = counts.by_rid.get(&(rid.clone(), "332".to_string()));
assert!(entry.is_some(), "car should appear in by_rid");
@ -240,7 +241,7 @@ proptest! {
);
let car_list = vec![make_car(&rid, rq, &guid)];
let counts = compute_car_counts(&ctx, car_list, empty_my_data());
let counts = compute_car_counts(&ctx, car_list, empty_my_data(), HashMap::new());
let (record, _) = counts.by_rid.get(&(rid, "332".to_string())).unwrap();
assert_eq!(record.owned, owned, "owned flag should propagate");