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:
parent
6a68469239
commit
89fa69e3c8
14 changed files with 874 additions and 2037 deletions
|
|
@ -175,6 +175,48 @@ This document describes the JSON data structures used by the Top Drives Records
|
|||
- Used for track-specific analysis queries
|
||||
- Supports condition filtering
|
||||
|
||||
### 5. Track Names Configuration (`track_names.json`)
|
||||
|
||||
**Purpose**: Maps internal track codes to human-readable track names.
|
||||
|
||||
**Source**: Included in the repository, loaded at compile time via `include_str!`
|
||||
|
||||
**Structure**:
|
||||
```json
|
||||
{
|
||||
"laguna": "Laguna Seca",
|
||||
"monaco": "Monaco Streets",
|
||||
"testBowl": "Test Bowl",
|
||||
"dealsGap": "Deals Gap"
|
||||
}
|
||||
```
|
||||
|
||||
**Field Descriptions**:
|
||||
|
||||
| Field | Type | Description |
|
||||
|-------|------|-------------|
|
||||
| *key* | String | Internal track code (e.g., `"laguna"`) |
|
||||
| *value* | String | Human-readable track name (e.g., `"Laguna Seca"`) |
|
||||
|
||||
**Usage in Application**:
|
||||
- Loaded by `translate_track_name()` in `src/lib.rs`
|
||||
- Compiled into the binary at build time
|
||||
- Fallback: Returns original track code if no mapping found
|
||||
|
||||
## Application Constants
|
||||
|
||||
### `MAX_RQ`
|
||||
|
||||
```rust
|
||||
const MAX_RQ: u8 = 113;
|
||||
```
|
||||
|
||||
**Purpose**: Defines the maximum RQ level used in analysis range calculations.
|
||||
|
||||
**Usage**: When evaluating car performance, each car is tested from its base RQ up to `MAX_RQ`. This replaces the former magic number 115, providing a named constant for clarity and easy adjustment.
|
||||
|
||||
**Location**: Defined in `src/records.rs`
|
||||
|
||||
## Data Processing Pipeline
|
||||
|
||||
### 1. Data Acquisition Phase
|
||||
|
|
@ -226,6 +268,11 @@ if let Some(configurations) = json_data["data"].as_object() {
|
|||
- Process: Split on `"_a"` delimiter
|
||||
- Output: `("laguna", "00")` (track name, condition code)
|
||||
|
||||
**Track Name Translation:**
|
||||
- Track codes are looked up in `track_names.json` (compiled into binary)
|
||||
- Example: `"laguna"` → `"Laguna Seca"`
|
||||
- Fallback: Unknown codes returned as-is
|
||||
|
||||
**Condition Code Translation:**
|
||||
- `"00"` → `"Dry"`
|
||||
- `"01"` → `"Wet"`
|
||||
|
|
@ -255,7 +302,7 @@ BestCarRecord {
|
|||
```
|
||||
|
||||
**RQ Range Analysis:**
|
||||
- Test each car from its base RQ up to 115
|
||||
- Test each car from its base RQ up to `MAX_RQ` (113)
|
||||
- Compare against existing best times
|
||||
- Update records if better performance found
|
||||
|
||||
|
|
@ -303,7 +350,7 @@ BestCarRecord {
|
|||
- User collection: Small, loaded once
|
||||
|
||||
**Optimization Strategies**:
|
||||
- Concurrent processing of car files
|
||||
- Concurrent processing of car files with bounded concurrency (semaphore limit of 20)
|
||||
- Rate-limited downloads (20 concurrent max)
|
||||
- Streaming JSON parsing where possible
|
||||
|
||||
|
|
@ -315,7 +362,7 @@ BestCarRecord {
|
|||
3. **HashMap Operations**: Frequent insertions with RQ range checking
|
||||
|
||||
**Optimizations Applied**:
|
||||
1. **Concurrency**: One task per car file
|
||||
1. **Bounded Concurrency**: Semaphore limits concurrent operations to 20
|
||||
2. **Connection Pooling**: Reuse HTTP connections
|
||||
3. **Early Filtering**: Invalid times rejected quickly
|
||||
|
||||
|
|
@ -361,8 +408,8 @@ BestCarRecord {
|
|||
|
||||
**Track Name Issues**:
|
||||
- **Symptom**: Unknown track codes in output
|
||||
- **Cause**: Outdated track definitions
|
||||
- **Solution**: Update `tracks_repo.json`
|
||||
- **Cause**: Missing mapping in `track_names.json`
|
||||
- **Solution**: Add new mapping to `track_names.json`
|
||||
|
||||
### Data Validation Tools
|
||||
|
||||
|
|
@ -404,4 +451,4 @@ grep -r "No RID" times/
|
|||
- Historical performance trends
|
||||
- Meta change impact analysis
|
||||
- Community submission quality metrics
|
||||
- Regional performance differences
|
||||
- Regional performance differences
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue