Skip to content

Latest commit

 

History

History
86 lines (66 loc) · 3.52 KB

File metadata and controls

86 lines (66 loc) · 3.52 KB

Util Functions Refactor Summary

Overview

Reorganized the monolithic util/api_proccesor.js (419 lines) into a clean, domain-specific folder structure with one function per file.

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.

Changes Made

✅ Preserved Original File

  • KEPT: util/api_proccesor.js - Original monolithic file remains unchanged
  • NOTE: Yes, it's misspelled as "proccesor" instead of "processor"
  • This ensures if any issues arise, the original file is still there for reference

✅ New Folder Structure

util/
├── api_proccesor.js                    # Original (unchanged, will be removed after merge)
├── curriculum/                         # Curriculum metadata & fetching (4 files)
│   ├── constants.js
│   ├── getAllTitlesAndDashedNamesSuperblockJSONArray.js
│   ├── getAllSuperblockTitlesAndDashedNames.js
│   └── getSuperblockTitlesInClassroomByIndex.js
├── dashboard/                          # Dashboard data transformation (2 files)
│   ├── createSuperblockDashboardObject.js
│   └── sortSuperBlocks.js
├── student/                            # Student progress & data (5 files)
│   ├── calculateProgress.js (3 functions)
│   │   • getTotalChallengesForSuperblocks
│   │   • getStudentProgressInSuperblock
│   │   • getStudentTotalChallengesCompletedInBlock
│   ├── checkIfStudentHasProgressDataForSuperblocksSelectedByTeacher.js
│   ├── extractTimestamps.js (2 functions)
│   │   • extractStudentCompletionTimestamps
│   │   • extractFilteredCompletionTimestamps
│   ├── fetchStudentData.js
│   └── getIndividualStudentData.js
└── legacy/                             # Deprecated v9-incompatible (3 files)
    ├── getDashedNamesURLs.js
    ├── getNonDashedNamesURLs.js
    └── getSuperBlockJsons.js

Total: 14 new organized files from 16 functions in the original monolithic file

✅ Files Modified (Only Import Changes)

6 files updated with new import paths (no logic changes):

  1. components/DetailsDashboard.js
  2. components/DetailsDashboardList.js
  3. components/dashtable_v2.js
  4. pages/dashboard/[id].js
  5. pages/dashboard/v2/[id].js
  6. pages/dashboard/v2/details/[id]/[studentEmail].js

All changes: Only import statements updated to point to new file locations

Benefits

  1. Easy to Find: Instead of searching through 419 lines, go directly to the file you need
  2. Clear Organization: Related functions grouped by domain (curriculum, student, dashboard)
  3. No Breaking Changes: Original file preserved, only imports updated
  4. Maintainability: One function per file = easier to understand and modify
  5. Better Discoverability: File names match function names exactly

Testing

  • ✅ ESLint: No errors
  • ✅ Prettier: All files formatted
  • ✅ Import Resolution: All imports validated
  • ✅ Diff Review: Only import path changes, no logic modifications
  • ✅ Comparison with main: Only functions from main's api_proccesor.js included

Visual Reference

See mermaid.md for an interactive diagram showing:

  • All organized folders and files
  • Function dependencies
  • Page/component imports
  • Legacy function warnings
  • Can be updated as needed.