refactor: extract lib.rs, remove club module, add bounded concurrency

- Extract shared types (Car, BestCarRecord, AnalysisContext) into src/lib.rs
- Replace global static BEST_CARS with injected AnalysisContext for testability
- Add semaphore-bounded concurrency (limit 20) in parse_all_times()
- Replace hardcoded track name match with track_names.json loaded via include_str!
- Replace magic number 115 with const MAX_RQ: u8 = 113
- Improve floating-point tie comparison with TIME_TOLERANCE (5ms) constant
- Remove src/club.rs binary (topdrives.club no longer maintained)
- Remove scraper dependency from Cargo.toml
- Remove tracks.txt (replaced by track_names.json)
- Remove empty/placeholder test bodies
- Improve error handling in get_file() for response body read
- Add load_my_cars_data() combining owned + wishlist extraction in one I/O
- Update CHANGELOG, README, and all docs to reflect changes
This commit is contained in:
Jan-Peter von Hunnius 2026-05-06 20:20:15 +02:00
parent 6a68469239
commit 89fa69e3c8
14 changed files with 874 additions and 2037 deletions

View file

@ -168,6 +168,7 @@ serde_json = "1.0.140"
- Parse `my_cars.json` (user collection)
- Parse individual car timing files
- Parse `tracks_repo.json` (track definitions)
- Parse `track_names.json` (track name mappings)
**Performance**: Zero-copy parsing where possible
@ -205,26 +206,9 @@ once_cell = "1.20.2"
- Thread-safe access during concurrent parsing
- Avoid expensive computation on every access
#### 6. `scraper` - HTML Parsing (Club Module Only)
```toml
scraper = "0.23.1"
```
**Purpose**: HTML parsing and CSS selector engine for web scraping
**Features Used**:
- CSS selector parsing with `Selector::parse()`
- HTML document parsing with `Html::parse_document()`
- Element selection and text extraction
**Why Needed**:
- Alternative data source for club.rs module
- Parse car data from topdrives.club HTML tables
- Extract performance information from web pages
### Development Dependencies
#### 7. Build Tools and Quality
#### 6. Build Tools and Quality
**Recommended additions for development:**
```toml
@ -289,9 +273,9 @@ name = "top_drives"
version = "0.2.0"
edition = "2021"
[[bin]]
name = "club"
path = "src/club.rs"
[lib]
name = "top_drives"
path = "src/lib.rs"
[[bin]]
name = "records"
@ -300,7 +284,6 @@ path = "src/records.rs"
**Binary Configuration:**
- **records**: Main analysis tool (JSON-based)
- **club**: Alternative scraper (web-based)
**Dependency Versions:**
- All dependencies pinned to specific versions for reproducibility
@ -342,7 +325,7 @@ RUST_BACKTRACE=1 cargo run
```
**Concurrency Tuning:**
- Default: 20 concurrent downloads (configurable via Semaphore)
- Default: 20 concurrent operations (bounded via Semaphore)
- Thread count: Automatic based on CPU cores
- Memory usage: ~100-200MB for full dataset
@ -471,7 +454,6 @@ cargo build --release
**Binary Location:**
```
target/release/records # Main analyzer
target/release/club # Club scraper
```
**Cross-Platform Building:**
@ -529,4 +511,4 @@ cargo profdata # Profile-guided optimization
- **Build Tool**: Cargo (included with Rust)
- **Editor**: VS Code with rust-analyzer (recommended)
- **Testing**: Built-in Rust testing framework
- **Debugging**: GDB/LLDB integration available
- **Debugging**: GDB/LLDB integration available