Skip to content

refactor: transition profile scripts to ES6 modules with global controller - #370

Merged
jagdish-15 merged 3 commits into
codepvg:mainfrom
Yashaswini-K-P:feature/global-profile-controller
Jul 31, 2026
Merged

refactor: transition profile scripts to ES6 modules with global controller#370
jagdish-15 merged 3 commits into
codepvg:mainfrom
Yashaswini-K-P:feature/global-profile-controller

Conversation

@Yashaswini-K-P

Copy link
Copy Markdown
Contributor

Description

Transitioned profile page frontend scripts (badges.js, contest.js, goal-setter.js, historical-graphs.js, and ranks.js) to modern ES6 modules orchestrated by a single profile-controller.js entry point. This eliminates redundant concurrent network requests to GET /api/user/:username on page load, cuts network overhead by 75%, and ensures smooth, synchronized UI rendering across all dashboard components.

Linked Issue

Fixes #292

Changes Made

  • Created a central profile-controller.js module to fetch user profile data exactly once on page load.
  • Refactored individual component scripts into ES6 modules accepting data payloads directly as arguments rather than triggering independent fetch calls.
  • Updated user.html to load the profile via a single <script type="module" src="/js/user/profile-controller.js"></script> tag.
  • Preserved strict username path resolution matching legacy structure.

Type of Change

  • Bug fix
  • New feature
  • UI/Visual update
  • Documentation update
  • Refactor

Testing

  • Tested locally
  • Tested on mobile viewport (if applicable)
  • No console errors introduced

Checklist

  • My code follows the project's coding style
  • I have formatted my code locally by running npx prettier --write . before submitting
  • I am submitting my PR from a dedicated feature/* branch, not the main branch
  • I have performed a self-review of my code
  • My changes generate no new warnings or errors
  • I have updated documentation if required
  • I have linked the relevant issue

Screenshots / Screen Recording

@github-actions

Copy link
Copy Markdown
Contributor

Thank you for submitting a pull request.

Please ensure your changes comply with the project's contribution guidelines and that all workflow checks pass successfully.

Formatting and Branching

  • Please confirm you have formatted your code locally using npx prettier --write . before requesting a review.
  • Ensure this PR is made from a feature/* branch and not main.

Note: This project is currently maintained by a solo maintainer, so reviews and responses may sometimes take a little time. Thanks for your patience.

Comment thread frontend/user.html Outdated
Comment thread frontend/js/user/ranks.js Outdated
@jagdish-15
jagdish-15 merged commit 5fe846a into codepvg:main Jul 31, 2026
1 check passed
@Yashaswini-K-P
Yashaswini-K-P deleted the feature/global-profile-controller branch July 31, 2026 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor: Consolidate Repetitive Profile API Fetch Calls

2 participants