Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
Commit History
-
refactor: extract utilities and improve type safety (Phases 1-3)
This PR implements a comprehensive refactoring to improve code maintainability and type safety without changing any functionality. ## Phase 1: Extract Constants - Created src/utils/constants.ts with centralized constants - Eliminated 40+ magic numbers (padding values, thresholds, config) - Updated all files to import from constants module ## Phase 2: Extract Business Logic - Created src/utils/dataProcessing.ts with chart processing functions - Extracted ~500 lines of duplicated scale grouping logic - Functions: groupRowBySuffix, computeGroupStats, groupByScale, etc. - Created src/utils/languageInstructions.ts for language extraction - Consolidates duplicate logic from v2 and v3 data fetching - Created src/utils/stringFormatting.ts for path formatting - Standard padding and path building utilities ## Phase 3: Improve Type Safety - Created src/utils/typeGuards.ts with type guard functions - Replaced 15+ unsafe type assertions with proper type guards - Added typed interfaces fo…2cbfbf8