|
| 1 | +# Util Functions Refactor Summary |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +Reorganized the monolithic `util/api_proccesor.js` (419 lines) into a clean, domain-specific folder structure with one function per file. |
| 6 | + |
| 7 | +**Note:** This is a pure refactor of functions that exist in main's `api_proccesor.js`. Functions from the `feat/graphql-curriculum-caching` branch (FCC Proper integration, challengeMap utilities) are preserved in the backup branch `refactor/organize-util-functions-with-fcc-proper` for later integration. |
| 8 | + |
| 9 | +## Changes Made |
| 10 | + |
| 11 | +### ✅ Preserved Original File |
| 12 | + |
| 13 | +- **KEPT**: `util/api_proccesor.js` - Original monolithic file remains unchanged |
| 14 | +- **NOTE**: Yes, it's misspelled as "proccesor" instead of "processor" |
| 15 | +- This ensures if any issues arise, the original file is still there for reference |
| 16 | + |
| 17 | +### ✅ New Folder Structure |
| 18 | + |
| 19 | +``` |
| 20 | +util/ |
| 21 | +├── api_proccesor.js # Original (unchanged, will be removed after merge) |
| 22 | +├── curriculum/ # Curriculum metadata & fetching (4 files) |
| 23 | +│ ├── constants.js |
| 24 | +│ ├── getAllTitlesAndDashedNamesSuperblockJSONArray.js |
| 25 | +│ ├── getAllSuperblockTitlesAndDashedNames.js |
| 26 | +│ └── getSuperblockTitlesInClassroomByIndex.js |
| 27 | +├── dashboard/ # Dashboard data transformation (2 files) |
| 28 | +│ ├── createSuperblockDashboardObject.js |
| 29 | +│ └── sortSuperBlocks.js |
| 30 | +├── student/ # Student progress & data (5 files) |
| 31 | +│ ├── calculateProgress.js (3 functions) |
| 32 | +│ │ • getTotalChallengesForSuperblocks |
| 33 | +│ │ • getStudentProgressInSuperblock |
| 34 | +│ │ • getStudentTotalChallengesCompletedInBlock |
| 35 | +│ ├── checkIfStudentHasProgressDataForSuperblocksSelectedByTeacher.js |
| 36 | +│ ├── extractTimestamps.js (2 functions) |
| 37 | +│ │ • extractStudentCompletionTimestamps |
| 38 | +│ │ • extractFilteredCompletionTimestamps |
| 39 | +│ ├── fetchStudentData.js |
| 40 | +│ └── getIndividualStudentData.js |
| 41 | +└── legacy/ # Deprecated v9-incompatible (3 files) |
| 42 | + ├── getDashedNamesURLs.js |
| 43 | + ├── getNonDashedNamesURLs.js |
| 44 | + └── getSuperBlockJsons.js |
| 45 | +``` |
| 46 | + |
| 47 | +**Total:** 14 new organized files from 16 functions in the original monolithic file |
| 48 | + |
| 49 | +### ✅ Files Modified (Only Import Changes) |
| 50 | + |
| 51 | +**6 files updated** with new import paths (no logic changes): |
| 52 | + |
| 53 | +1. `components/DetailsDashboard.js` |
| 54 | +2. `components/DetailsDashboardList.js` |
| 55 | +3. `components/dashtable_v2.js` |
| 56 | +4. `pages/dashboard/[id].js` |
| 57 | +5. `pages/dashboard/v2/[id].js` |
| 58 | +6. `pages/dashboard/v2/details/[id]/[studentEmail].js` |
| 59 | + |
| 60 | +**All changes**: Only import statements updated to point to new file locations |
| 61 | + |
| 62 | +## Benefits |
| 63 | + |
| 64 | +1. **Easy to Find**: Instead of searching through 419 lines, go directly to the file you need |
| 65 | +2. **Clear Organization**: Related functions grouped by domain (curriculum, student, dashboard) |
| 66 | +3. **No Breaking Changes**: Original file preserved, only imports updated |
| 67 | +4. **Maintainability**: One function per file = easier to understand and modify |
| 68 | +5. **Better Discoverability**: File names match function names exactly |
| 69 | + |
| 70 | +## Testing |
| 71 | + |
| 72 | +- ✅ ESLint: No errors |
| 73 | +- ✅ Prettier: All files formatted |
| 74 | +- ✅ Import Resolution: All imports validated |
| 75 | +- ✅ Diff Review: Only import path changes, no logic modifications |
| 76 | +- ✅ Comparison with main: Only functions from main's api_proccesor.js included |
| 77 | + |
| 78 | +## Visual Reference |
| 79 | + |
| 80 | +See `mermaid.md` for an interactive diagram showing: |
| 81 | + |
| 82 | +- All organized folders and files |
| 83 | +- Function dependencies |
| 84 | +- Page/component imports |
| 85 | +- Legacy function warnings |
| 86 | +- Can be updated as needed. |
0 commit comments