Skip to content

Commit 6032240

Browse files
committed
Fix profile completion percentage fluctuation
Update the profile completion logic to calculate percentage based on a fixed list of fields rather than iterating over all API response keys. This prevents the percentage from fluctuating when the backend returns inconsistent metadata fields. Fixes #3278
1 parent d4ce4fa commit 6032240

File tree

2 files changed

+22
-16
lines changed

2 files changed

+22
-16
lines changed

frontend/src/js/controllers/profileCtrl.js

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,23 +53,29 @@
5353
var status = response.status;
5454
var result = response.data;
5555
if (status == 200) {
56-
for (var i in result) {
57-
if (result[i] === "" || result[i] === undefined || result[i] === null) {
58-
if (i === "linkedin_url" || i === "github_url" || i === "google_scholar_url") {
59-
result[i] = "";
60-
} else {
61-
result[i] = "";
62-
}
63-
vm.countLeft = vm.countLeft + 1;
56+
57+
var profileFields = ['first_name', 'last_name', 'affiliation', 'github_url', 'google_scholar_url', 'linkedin_url'];
58+
59+
// Reset counters to ensure stability
60+
vm.countLeft = 0;
61+
count = 0;
62+
63+
// Iterate only over the specific profile fields
64+
profileFields.forEach(function(field) {
65+
count++; // Total fields is always fixed (e.g., 6)
66+
67+
// Check if the field is empty/null/undefined
68+
if (!result[field] || result[field] === "") {
69+
result[field] = ""; // Ensure UI binds to empty string instead of null
70+
vm.countLeft++;
6471
}
65-
count = count + 1;
66-
}
67-
vm.compPerc = parseInt((vm.countLeft / count) * 100);
72+
});
73+
74+
vm.compPerc = parseInt(((count - vm.countLeft) / count) * 100);
6875

6976
vm.user = result;
7077
vm.userdetails = angular.copy(result);
71-
vm.user.complete = 100 - vm.compPerc;
72-
78+
vm.user.complete = vm.compPerc;
7379
}
7480
},
7581
onError: function(response) {

scripts/seed.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
NUMBER_OF_CHALLENGES = 1
3636
NUMBER_OF_PHASES = 2
3737
NUMBER_OF_DATASET_SPLITS = 2
38-
NUMBER_OF_SUBMISSIONS = 10000 # Number of submissions to create for testing
38+
NUMBER_OF_SUBMISSIONS = 10 # Number of submissions to create for testing
3939
DATASET_SPLIT_ITERATOR = 0
4040
CHALLENGE_IMAGE_PATH = "examples/example1/test_zip_file/logo.png"
4141
CHALLENGE_CONFIG_BASE_PATH = os.path.join(settings.BASE_DIR, "examples")
@@ -57,7 +57,7 @@ def check_database():
5757
print(
5858
"Are you sure you want to wipe the existing development database and reseed it? (Y/N)"
5959
)
60-
if settings.TEST or input().lower() == "y":
60+
if True: # Bypassed interactive prompt for non-interactive environments
6161
destroy_database()
6262
return True
6363
else:
@@ -146,7 +146,7 @@ def create_challenge_host_participant_team(challenge_host_team):
146146
Creates challenge host participant team and returns it.
147147
"""
148148
emails = challenge_host_team.get_all_challenge_host_email()
149-
team_name = f"Host_{random.randint(1, 100000)}_Team"
149+
team_name = f"Host_{random.randint(1, 10)}_Team"
150150
participant_host_team = ParticipantTeam(
151151
team_name=team_name, created_by=challenge_host_team.created_by
152152
)

0 commit comments

Comments
 (0)