75 lines
3.3 KiB
Markdown
75 lines
3.3 KiB
Markdown
---
|
|
id: 4dc83eed-b0b1-4924-b82e-faf352426785
|
|
type: decision
|
|
title: "SBA Scout Rust rewrite Phase 2 complete — API client, sync, and CSV importers"
|
|
tags: [sba-scout, rust, migration, phase-2, reqwest, api, csv, serde]
|
|
importance: 0.8
|
|
confidence: 0.8
|
|
created: "2026-02-28T04:57:59.820017+00:00"
|
|
updated: "2026-02-28T16:53:43.054882+00:00"
|
|
relations:
|
|
- target: c9add129-283a-445a-8dff-4525ec7fa9b6
|
|
type: FOLLOWS
|
|
direction: outgoing
|
|
strength: 1.0
|
|
edge_id: 6dc75271-96a2-43f4-ad96-cfc26ce126c1
|
|
- target: 27a1f728-ec90-469c-a6ab-5644d333322f
|
|
type: RELATED_TO
|
|
direction: outgoing
|
|
strength: 0.9
|
|
edge_id: f57f63b8-1a05-4645-a320-4b045569ff55
|
|
- target: 3ecd877b-de73-4afd-b328-b3ee99f5a1e3
|
|
type: CAUSES
|
|
direction: incoming
|
|
strength: 0.8
|
|
edge_id: 235a68a1-bb13-43e0-9784-4b8561f7685a
|
|
- target: 2cf3058c-85f4-481a-bbe7-17ebb9b9e908
|
|
type: FOLLOWS
|
|
direction: outgoing
|
|
strength: 0.7
|
|
edge_id: b8e47bac-8b05-4e2c-b0a0-bd7683ced31f
|
|
- target: 0e484de1-cb92-479c-95ec-06fa9e886c0c
|
|
type: FOLLOWS
|
|
direction: incoming
|
|
strength: 0.9
|
|
edge_id: c32c4588-17b5-4f00-8d59-37bf89c6f6be
|
|
- target: bc4abc6e-57c1-4d6c-b414-213c1367be9b
|
|
type: FOLLOWS
|
|
direction: incoming
|
|
strength: 0.9
|
|
edge_id: 0868f506-7c16-49a6-8d1c-0ced9d74a9cc
|
|
- target: 23121a41-790a-4bf3-9a4b-39f299bc4015
|
|
type: RELATED_TO
|
|
direction: incoming
|
|
strength: 0.8
|
|
edge_id: 5df40dff-4569-4471-96e7-fe1234d93b36
|
|
- target: d5b6584e-ae9d-4462-aeb0-eac103156dfc
|
|
type: RELATED_TO
|
|
direction: incoming
|
|
strength: 0.8
|
|
edge_id: 5fb91cf0-1aa3-4e71-af81-29c1e43730a9
|
|
---
|
|
|
|
# SBA Scout Rust Rewrite — Phase 2 Complete
|
|
|
|
Phase 2 (API Client + Sync + CSV Import) committed as `3c70ecc` on branch `feat/rust-rewrite`. 1,580 lines across 6 files.
|
|
|
|
## Files Implemented
|
|
|
|
- **`api/types.rs`** (175 lines): Serde response types with `#[serde(rename)]` for API field mismatches (`sname`→`short_name`, `wara`→`swar`, `gmid`→`gm_discord_id`, etc.)
|
|
- **`api/client.rs`** (225 lines): `ApiError` enum (Http/CloudflareBlocked/Request/Parse) + `LeagueApiClient` with core `get<T>()` and 10 endpoint methods
|
|
- **`api/sync.rs`** (243 lines): `sync_teams` (INSERT OR REPLACE), `sync_players` (ON CONFLICT omitting `hand` to preserve CSV data), `sync_transactions` (ON CONFLICT on composite key), `sync_all` orchestrator
|
|
- **`api/importer.rs`** (666 lines): `parse_float`/`parse_int`/`parse_endurance` helpers, `import_batter_cards` (30+ column mapping), `import_pitcher_cards` (different header names, endurance parsing), `import_all_cards` (resilient — tries both CSVs independently)
|
|
|
|
## Key Decisions
|
|
|
|
- **Serde rename**: `#[serde(rename = "...")]` handles API field name mismatches at deserialization layer — cleaner than manual mapping
|
|
- **sync_players ON CONFLICT**: Uses `DO UPDATE SET ... (excluding hand column)` to preserve hand data from CSV imports while updating all other fields from API
|
|
- **import_all_cards resilience**: Doesn't abort if one CSV is missing — tries both independently so partial data is still loaded
|
|
- **response.text() + serde_json::from_str()**: Used instead of `response.json()` to properly populate `ApiError::Parse(serde_json::Error)` variant (see related fix memory)
|
|
|
|
## Relates To
|
|
|
|
- Phase 1 decision: c9add129 (foundation layer — DB schema, queries, config)
|
|
- Branch: `feat/rust-rewrite`
|