-
Notifications
You must be signed in to change notification settings - Fork 19
Issue#252552 Feat: User bulk upload with all entity types #869
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Issue#252552 Feat: User bulk upload with all entity types #869
Conversation
WalkthroughAdds a null-check when resolving an entity's data_type during ARRAY lookups, and replaces hard-coded root field deletions in user invite processing with dynamic iteration over entityFields to populate row.meta from externalEntityNameIdMap and remove processed fields. Changes
Sequence Diagram(s)(Skipped — changes do not introduce a new multi-component control flow requiring visualization.) Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
✏️ Tip: You can disable this entire section by setting Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/helpers/userInvite.js`:
- Around line 352-364: The dynamic entityFields loop currently only assigns a
single _id into row.meta[field]; update the entityFields.forEach handler (the
loop that checks alreadyProcessed and uses externalEntityNameIdMap and
lookupKey) to detect ARRAY-like values (either actual arrays or comma-separated
strings), split them into items, clean each item with the same
whitespace/lowercase logic, build per-item lookupKeys and map to IDs via
externalEntityNameIdMap, and then set row.meta[field] to an array of IDs (or
null/empty array if none); if the value is a single scalar, keep the existing
single-ID assignment behavior. Ensure you reuse the same cleaning logic and
externalEntityNameIdMap lookup so behavior matches professional_subroles
handling.
🧹 Nitpick comments (2)
src/helpers/userInvite.js (2)
366-370: Consider deduplicating fields to delete.If
alreadyProcessedfields are also present inentityFields, you'll iterate over them twice. While harmless (deleting a non-existent key is a no-op), using aSetwould be cleaner.♻️ Optional: Use Set to deduplicate
-const allFieldsToDelete = [...alreadyProcessed, ...entityFields] -allFieldsToDelete.forEach((field) => { - delete row[field] -}) +const allFieldsToDelete = new Set([...alreadyProcessed, ...entityFields]) +allFieldsToDelete.forEach((field) => { + delete row[field] +})
341-370: Consider consolidating entity processing in future refactor.The code now has two processing paths: hardcoded handling (lines 283-339) for 7 specific fields and dynamic handling (lines 352-364) for additional fields. While this works, it increases maintenance burden. Consider consolidating all entity field processing into the dynamic loop in a future iteration.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/generics/utils.jssrc/helpers/userInvite.js
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-08-08T13:06:32.911Z
Learnt from: nevil-mathew
Repo: ELEVATE-Project/user PR: 790
File: src/helpers/userHelper.js:10-10
Timestamp: 2025-08-08T13:06:32.911Z
Learning: In ELEVATE-Project/user, avoid potential circular dependencies between src/helpers/userHelper.js and src/services/user-sessions by extracting shared session cleanup logic (finding active sessions, deleting Redis keys, ending sessions) into a dedicated utility (e.g., helpers/sessionCleanup.js) that both layers can consume.
Applied to files:
src/helpers/userInvite.js
🧬 Code graph analysis (1)
src/helpers/userInvite.js (1)
src/validators/v1/admin.js (1)
field(161-161)
🔇 Additional comments (1)
src/generics/utils.js (1)
1041-1041: LGTM! Good defensive check.The guard prevents a potential
TypeErrorwhenprunedEntities.find()returnsundefinedfor ametaKeythat doesn't match any entity.
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
Summary by CodeRabbit
Bug Fixes
Improvements
✏️ Tip: You can customize this high-level summary in your review settings.