Skip to content

Commit 838e532

Browse files
committed
Fix add users
1 parent 6c4c214 commit 838e532

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

src/python/add_update_member.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,17 @@ def merge_profile_data(old_profile: Dict, new_profile: Dict) -> Dict:
108108

109109
# Update current role if provided
110110
if "current_role" in new_profile:
111-
merged["current_role"] = new_profile["current_role"]
111+
# Preserve existing fields that aren't being updated
112+
if "current_role" in merged:
113+
existing_role = merged["current_role"]
114+
new_role = new_profile["current_role"]
115+
116+
# Update each field only if it exists in the new data
117+
for field in ["type", "title", "start_date", "advisor", "affiliation", "research_directions"]:
118+
if field in new_role:
119+
existing_role[field] = new_role[field]
120+
else:
121+
merged["current_role"] = new_profile["current_role"]
112122

113123
# Handle past roles
114124
if "past_roles" in new_profile:

tests/data/update_member/in.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ Unaffiliated
3030

3131
Professing at Leland S. Junior University
3232

33+
### Current_role-research-directions
34+
35+
online-toxicity, poli-sci, online-crime
36+
3337
### Current_role-advisor
3438

3539
_No response_

tests/data/update_member/out.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@
77
"auto_update_publications": true,
88
"current_role": {
99
"type": "Unaffiliated",
10-
"title": "Professing at Leland S. Junior University"
10+
"title": "Professing at Leland S. Junior University",
11+
"research_directions": [
12+
"online-toxicity",
13+
"poli-sci",
14+
"online-crime"
15+
]
1116
},
1217
"past_roles": [
1318
{

0 commit comments

Comments
 (0)