Fix profile completion percentage fluctuation #4828
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes Issue #3278 where the profile completion percentage would fluctuate (e.g., 40% -> 100% -> 40%) on page refresh.
The Cause:
The previous logic iterated over all properties returned by the user API (
for var i in result). Since the backend response structure can vary (including/excluding metadata fields or changing order), the total field countcountwas inconsistent. This caused the percentage calculation(countLeft / count) * 100to produce random results on refresh.The Fix:
Updated
profileCtrl.jsto calculate completion based on a predefined list of relevant profile fields (first_name,last_name,affiliation, etc.) instead of iterating over the entire response object. This ensures the denominator is always constant.Related Issue
Fixes #3278
How Has This Been Tested?
docker-compose.