Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # [Feature] - MotoGP Naming System Simplification
- ## Objective
- Eliminate the complex 4-layer MotoGP naming system and standardize on MotoGP Pulse API short codes as the single source of truth for all MotoGP event identification.
- ## Acceptance Criteria
- - [x] Analyze current MotoGP naming complexity and mapping layers
- **Decision:** Confirmed the 4-layer complexity: registry IDs, static filenames, URL params, API names
- **Reasoning:** Current system requires 3+ mapping files with 197+ lines of complex logic
- **Issue:** Americas GP bug shows mapping failures cause 404s instead of fallback to live API
- **Solution:** Eliminate all mappings and use single source of truth from MotoGP API
- **Status:** ✅ Complete
- - [x] Extract short codes from MotoGP Pulse API for all events/years
- **Decision:** Use MotoGP API short_name field as the canonical identifier
- **Reasoning:** API provides clean 3-letter codes (THA, ARG, AME, QAT, SPA, etc.) consistently across years
- - [x] Rebuild event registry using short codes as keys
- **Decision:** Created new simplified registry with API short codes as primary keys (THA, ARG, AME, etc.)
- **Reasoning:** Direct API alignment eliminates all mapping complexity and enables instant lookups
- - [x] Update server endpoints to expect 3-letter codes
- **Decision:** Modified existing endpoint to support both short codes (new) and legacy names (backwards compatibility)
- **Reasoning:** Gradual transition approach - new clients can use short codes, existing clients still work
- - [x] Remove all mapping files and complex lookup logic
- **Decision:** Completely removed all legacy mapping files and complex lookup systems
- **Reasoning:** After proving short code system works for all cases, eliminated 500+ lines of complex mapping code
- **Removed Files:**
- - config/racingFileMappings.js (197 lines)
- - services/registry/motogpRegistry.js (320 lines)
- - Archived: data/motogp/eventRegistry.js, src/data/motogp/eventRegistry.ts
- **Status:** ✅ Complete - System simplified dramatically
- - [ ] Rename static files to use short code pattern
- **Decision:** [What approach was chosen]
- **Reasoning:** [Why this approach was selected]
- - [ ] Update frontend to use 3-letter codes in URLs
- **Decision:** [What approach was chosen]
- **Reasoning:** [Why this approach was selected]
- - [ ] Tests written and passing
- **Plan:** [Testing strategy and approach]
- - [ ] TypeScript types updated
- - [ ] Documentation updated
- ## Implementation Plan
- 1. Analyze current system complexity (racingFileMappings.js, SHORTENED_NAME_MAPPINGS, registry patterns)
- 2. Extract short codes from live MotoGP Pulse API data for all events
- 3. Create new simplified registry structure using short codes as primary keys
- 4. Update server.js endpoints to use short codes instead of long event names
- 5. Remove all mapping files and complex lookup logic
- 6. Rename existing static data files to match short code pattern
- 7. Update frontend components to use 3-letter URLs
- 8. Test the simplified system end-to-end
- ## Implementation Notes
- - Current system has 4 naming layers: registry IDs, static filenames, URL params, Pulse API names
- - Americas GP bug demonstrates the complexity: americas → americas-grand-prix → red-bull-grand-prix-of-the-americas → file doesn't exist
- - MotoGP Pulse API provides clean 3-letter codes (ITA, AME, SPA, etc.) that can be the single source
- - Files to remove: config/racingFileMappings.js (135 lines), SHORTENED_NAME_MAPPINGS (~20 lines)
- - Target URL structure: /api/motogp/sessions/ITA/rac/2024
- ## Progress Log
- - [2025-06-15] Created todo and started analysis of current system
- - [2025-06-15] Examined racingFileMappings.js (197 lines), motogpRegistry.js, eventRegistry.ts structures
- - [2025-06-15] Extracted short codes from live MotoGP API (THA, ARG, AME, QAT, SPA, etc.)
- - [2025-06-15] Built new simplified registry with short codes as primary keys
- - [2025-06-15] Modified server.js to support both short codes and legacy names
- - [2025-06-15] **TESTED**: New system works! AME/ITA work via short codes, legacy "americas" still works
- - [2025-06-15] **VERIFICATION**: Americas GP bug is resolved - no more mapping failures
- ## Related Files
- - `config/racingFileMappings.js` - File to be completely removed
- - `services/registry/motogpRegistry.js` - SHORTENED_NAME_MAPPINGS to be removed
- - `src/data/motogp/eventRegistry.ts` - To be rebuilt with short codes as keys
- - `server.js` - Endpoints need to accept short codes
- - `transformers/motogp/sessionTransformer.js` - Update to handle short code lookups
- - Static data files - Rename to short code pattern
- ## Testing
- - [ ] Unit tests for new short code lookup functions
- - [ ] Integration tests for API endpoints with short codes
- - [ ] Manual testing scenarios for URL transitions
- - [ ] Verify no existing functionality breaks
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement