Release v0.3.0: CSV output, wishlist commands, improved error handling

- Replace stdout output with structured CSV file generation
- Add wishlist, all commands with --min-count and --max-wishlist flags
- Introduce CarCounts struct for shared analysis computation
- Improve error handling: return Result instead of unwrap/panic
- Add prize field to BestCarRecord
- Remove TODO.md
This commit is contained in:
Jan-Peter von Hunnius 2026-05-07 20:13:30 +02:00
parent 08c96d9981
commit 9d57b18a4e
8 changed files with 697 additions and 594 deletions

View file

@ -18,9 +18,10 @@ This guide provides comprehensive instructions for using the Top Drives Records
**Export your car collection from Top Drives:**
1. Open Top Drives on your device
2. Go to Settings → Account → Export Data
3. Save the file as `my_cars.json` in the project directory
1. Set up HTTP interception (HTTP Toolkit)
2. Open Top Drives on an emulator (Bluestacks)
3. Intercept transmission of your game data
4. Save to file `my_cars.json` in the project directory
### 2. Initial Data Download
@ -55,9 +56,19 @@ Fetching https://api.topdrivesrecords.com/car/1002.json.
cargo run --bin records -- best
```
**Purpose:** Shows the best performing cars in your collection, ranked by how often they achieve top times.
**Purpose:** Generates `best.csv` (all cars best on at least one track) and `very_best.csv` (cars best on ≥10 tracks). Both files are sorted by RQ.
**Sample Output:**
**Flags:**
- `--min-count N` — Minimum number of tracks a car must be best on to qualify as "very best" (default: 10)
**Example with custom threshold:**
```bash
cargo run --bin records -- best --min-count 5
```
**Output Files:**
`best.csv`:
```csv
RQ,Brand,Model,Year,Count
85,McLaren,F1,1993,15
@ -66,6 +77,13 @@ RQ,Brand,Model,Year,Count
75,Porsche,911 Turbo,1975,6
```
`very_best.csv`:
```csv
RQ,Brand,Model,Year,Count
85,McLaren,F1,1993,15
82,Ferrari,250 GTO,1962,12
```
**Understanding the output:**
- **RQ**: Car's rarity level
- **Brand**: Car manufacturer
@ -78,38 +96,18 @@ RQ,Brand,Model,Year,Count
- Focus on cars with counts ≥ 5 for your core collection
- Compare with your owned cars to identify strengths
#### Missing Cars Analysis
**Command:**
```bash
cargo run --bin records -- missing
```
**Purpose:** Identifies high-performing cars you don't own that would improve your collection.
**Sample Output:**
```csv
RQ,Brand,Model,Year,Count
90,Pagani,Zonda R,2010,18
88,Ferrari,F40,1987,15
87,McLaren,Senna,2018,12
```
**Action items:**
- Prioritize cars with high counts (≥10)
- Consider RQ restrictions in your racing bracket
- Look for cars that perform well across multiple track types
#### Collection Optimization (Trash Analysis)
#### Trash Analysis
**Command:**
```bash
cargo run --bin records -- trash
```
**Purpose:** Identifies cars safe to remove from your collection.
**Purpose:** Generates `trash.csv` — owned cars that are not best on any track, have RQ < 80, and are not prize cars. Sorted by RQ.
**Sample Output:**
**Output File:**
`trash.csv`:
```csv
RQ,Brand,Model,Year
45,Toyota,Corolla,1995
@ -123,6 +121,84 @@ RQ,Brand,Model,Year
- Only suggests cars that never achieve best times
- **Always verify before selling in-game**
#### Wishlist Management
**Command:**
```bash
cargo run --bin records -- wishlist
```
**Purpose:** Generates three files for wishlist optimization:
- `wishlist.csv` — Ideal wishlist: very_best unowned cars, capped at 300
- `add.csv` — Cars that should be on your wishlist but aren't
- `remove.csv` — Cars on your wishlist that shouldn't be
All files are sorted by RQ.
**Flags:**
- `--min-count N` — Minimum number of tracks for "very best" qualification (default: 10)
- `--max-wishlist M` — Maximum number of cars on the ideal wishlist (default: 300)
**Example with custom flags:**
```bash
cargo run --bin records -- wishlist --min-count 5 --max-wishlist 500
```
**Output Files:**
`wishlist.csv`:
```csv
RQ,Brand,Model,Year,Count
90,Pagani,Zonda R,2010,18
88,Ferrari,F40,1987,15
87,McLaren,Senna,2018,12
```
`add.csv`:
```csv
RQ,Brand,Model,Year,Count
90,Pagani,Zonda R,2010,18
88,Ferrari,F40,1987,15
```
`remove.csv`:
```csv
RQ,Brand,Model,Year,Count
75,BMW,M3,2003,3
72,Audi,RS6,2002,2
```
**Action items:**
- Add cars from `add.csv` to your in-game wishlist
- Remove cars from `remove.csv` from your in-game wishlist
- Use `wishlist.csv` as your target wishlist
#### Full Analysis
**Command:**
```bash
cargo run --bin records -- all
```
**Purpose:** Generates all 6 CSV files in a single parse pass. Equivalent to running `best`, `trash`, and `wishlist` together, but more efficient since data is only parsed once.
**Flags:**
- `--min-count N` — Minimum number of tracks for "very best" qualification (default: 10)
- `--max-wishlist M` — Maximum number of cars on the ideal wishlist (default: 300)
**Example with custom flags:**
```bash
cargo run --bin records -- all --min-count 5 --max-wishlist 500
```
**Output Files:**
- `best.csv` — All cars best on at least one track
- `very_best.csv` — Cars best on ≥ min_count tracks
- `trash.csv` — Owned cars safe to remove
- `wishlist.csv` — Ideal wishlist (very_best unowned, capped)
- `add.csv` — Cars to add to wishlist
- `remove.csv` — Cars to remove from wishlist
#### Detailed Performance Data
**Command:**
@ -130,7 +206,7 @@ RQ,Brand,Model,Year
cargo run --bin records -- details
```
**Purpose:** Comprehensive timing data for all tracks and conditions.
**Purpose:** Generates `details.csv` with comprehensive timing data for all tracks and conditions.
**Sample Output:**
```csv
@ -152,7 +228,7 @@ RQ,TrackID,Condition,CarRQ,Brand,Model,Year,Config,Time
cargo run --bin records -- track "Laguna Seca" "Dry" "85"
```
**Purpose:** Find the best car for a specific track, condition, and RQ level.
**Purpose:** Prints the best car for a specific track, condition, and RQ level to stdout.
**Sample Output:**
```
@ -169,42 +245,53 @@ Best car for Track: laguna, Condition: Dry, RQ: 85 -> McLaren F1 (1993) with tim
- `Dirt` - Off-road tracks
- `Snow` - Winter conditions
### Command Flags Reference
| Flag | Applicable Commands | Default | Description |
|------|-------------------|---------|-------------|
| `--min-count N` | `best`, `wishlist`, `all` | `10` | Minimum tracks a car must be best on to qualify as "very best" |
| `--max-wishlist M` | `wishlist`, `all` | `300` | Maximum number of cars on the ideal wishlist |
## Daily Workflow
The recommended daily workflow uses the `full_script` command, which runs `fetch` followed by all analysis commands in a single pipeline:
The recommended daily workflow uses the `all` command, which runs all analysis in a single efficient parse pass:
```bash
cargo run --bin records -- full_script
cargo run --bin records -- fetch
cargo run --bin records -- all
```
### What `full_script` Does
Or combine them:
```bash
cargo run --bin records -- fetch && cargo run --bin records -- all
```
1. **Fetches** fresh data from the community repository
2. **Runs** all analysis commands sequentially
3. **Generates** all output CSV files
### What `all` Does
1. **Parses** all timing data in a single pass
2. **Generates** all 6 output CSV files
3. **Sorts** all files by car RQ
### Output Files
| File | Purpose | Format |
|------|---------|--------|
| `best.csv` | Ranked list of best cars — evaluate if a car is worth keeping | `RQ,Brand,Model,Year,Count` |
| `details.csv` | Detailed timing data for all tracks/conditions — find best config for a car | `RQ,TrackID,Condition,CarRQ,Brand,Model,Year,Config,Time` |
| `add.csv` | Cars to add to wishlist — missing cars not yet wishlisted, prefixed with `+` | `+RQ,Brand,Model,Year` |
| `remove.csv` | Cars to remove from wishlist — stale wishlist entries, prefixed with `-` | `-RQ,Brand,Model,Year` |
| `trash.csv` | Owned cars that can be safely removed | `RQ,Brand,Model,Year` |
| `sorted.csv` | Best cars sorted by count (descending) | `RQ,Brand,Model,Year,Count` |
| `very_best.csv` | Best cars with count ≥ 10 | `RQ,Brand,Model,Year,Count` |
| `wishlist.csv` | Missing cars already on wishlist | `RQ,Brand,Model,Year,Count` |
| File | Format | Description |
|------|--------|-------------|
| `best.csv` | `RQ,Brand,Model,Year,Count` | All cars best on at least one track |
| `very_best.csv` | `RQ,Brand,Model,Year,Count` | Cars best on ≥ min_count tracks |
| `trash.csv` | `RQ,Brand,Model,Year` | Owned cars not best on any track (RQ<80, not prize) |
| `wishlist.csv` | `RQ,Brand,Model,Year,Count` | Ideal wishlist (very_best unowned, capped) |
| `add.csv` | `RQ,Brand,Model,Year,Count` | Cars to add to wishlist |
| `remove.csv` | `RQ,Brand,Model,Year,Count` | Cars to remove from wishlist |
### Typical Daily Routine
1. **Run `full_script`** to get fresh data and full analysis
2. **Review `best.csv`** to see how your cars rank overall
3. **Check `add.csv`** for cars worth adding to your wishlist (prefixed with `+`)
4. **Check `remove.csv`** for wishlist entries to remove (prefixed with `-`)
5. **Review `trash.csv`** for owned cars you can safely sell
6. **Use `details.csv`** to find the optimal tune config for a specific car
7. **Check `very_best.csv`** for the absolute top performers (count ≥ 10)
1. **Run `fetch`** to get fresh data from the community repository
2. **Run `all`** to generate all analysis files in one pass
3. **Review `best.csv`** to see how your cars rank overall
4. **Check `add.csv`** for cars worth adding to your wishlist
5. **Check `remove.csv`** for wishlist entries to remove
6. **Review `trash.csv`** for owned cars you can safely sell
7. **Check `very_best.csv`** for the absolute top performers
## Advanced Usage
@ -232,9 +319,9 @@ cargo run --bin records -- best
- Note RQ distribution
- Find gaps in coverage
#### Step 2: Identify Priorities
#### Step 2: Identify Wishlist Priorities
```bash
cargo run --bin records -- missing
cargo run --bin records -- wishlist
```
- Focus on high-count cars in your RQ range
- Consider track variety needs
@ -271,30 +358,38 @@ Different cars excel on different track types:
### CSV File Usage
The tool generates CSV files for external analysis:
The tool generates CSV files for external analysis. All files are sorted by car RQ.
#### best.csv
- Your best performing cars
- All cars that are best on at least one track (owned and unowned)
- Import into spreadsheet for sorting/filtering
- Track performance across time
#### details.csv
- Comprehensive timing database
- Advanced analysis and research
- Historical performance tracking
#### add.csv / remove.csv
- Wishlist management
- `+` prefix indicates cars to add
- `-` prefix indicates cars to remove
#### very_best.csv
- Cars best on ≥ min_count tracks (default ≥10)
- These are the most versatile performers
- Use `--min-count N` to adjust the threshold
#### trash.csv
- Cars safe to sell from your collection
- Owned cars safe to sell from your collection
- Only includes cars with RQ < 80 that are not best on any track
- Excludes prize cars
- Cross-reference with your garage before selling
#### sorted.csv / very_best.csv
- Sorted rankings by versatility
- `very_best.csv` filters to count ≥ 10 for top-tier recommendations
#### wishlist.csv
- Ideal wishlist: very_best cars you don't own, capped at max-wishlist (default 300)
- Sorted by RQ
- Use as your target wishlist
#### add.csv
- Cars that should be on your wishlist but aren't
- These are very_best unowned cars not currently on your wishlist
- Add these to your in-game wishlist
#### remove.csv
- Cars currently on your wishlist that shouldn't be
- These are cars on your wishlist that don't qualify as very_best
- Remove these from your in-game wishlist
### Spreadsheet Analysis Tips
@ -310,7 +405,7 @@ The tool generates CSV files for external analysis:
#### "Please provide a command"
**Problem:** No arguments provided
**Solution:** Use `best`, `missing`, `trash`, `details`, `track`, or `full_script`
**Solution:** Use `best`, `trash`, `wishlist`, `all`, `details`, `track`, or `fetch`
#### "Could not read my cars file"
**Problem:** `my_cars.json` not found or not readable
@ -348,8 +443,8 @@ The tool generates CSV files for external analysis:
## Tips and Best Practices
### Regular Maintenance
1. **Daily**: Run `full_script` to get latest data and full analysis
2. **Weekly**: Review `missing` cars for new acquisitions
1. **Daily**: Run `fetch` then `all` to get latest data and full analysis
2. **Weekly**: Review `wishlist` output for new acquisitions
3. **Monthly**: Use `trash` to optimize collection
### Data-Driven Decisions