refactor(person-factory): align Person.create call with other factories - #1745
Conversation
3b3d76a to
5c2f67a
Compare
greenscientist
left a comment
There was a problem hiding this comment.
Please explain why you need to omit nested journeys. (At least in the commit message, but it probably need a comment in the code also.
5c2f67a to
8d8ac14
Compare
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
📜 Recent review details🧰 Additional context used🧠 Learnings (1)📚 Learning: 2026-03-31T18:20:32.322ZApplied to files:
🔇 Additional comments (5)
Walkthrough
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
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 |
Ajouté au commit message |
8d8ac14 to
40b5baa
Compare
|
|
||
| // Verify person and journey factories were called | ||
| // Verify person factory was called (journeys/setupWorkAndSchoolPlaces are now | ||
| // triggered from within populatePersonsForHousehold, covered by PersonFactory.test.ts) |
There was a problem hiding this comment.
On n'a pas besoin de savoir ça, "are now triggered", now par rapport à quoi? Ceci est un commentaire justifiant le changement (genre dans le commit message), ça ne va pas dans le code
| // Journey.create in JourneyFactory: it is a nested child collection, not a Person | ||
| // attribute. Once the person itself is successfully created, populateJourneysForPerson | ||
| // builds each journey individually so that per-journey errors are tracked separately | ||
| // instead of failing the whole Person.create call. |
There was a problem hiding this comment.
Svp, revoir les commentaires écrits par Claude, souvent, ils ne sont pas pertinents dans le code et ne font qu'expliquer pouquoi le changement a été fait. Il faut lire ce commentaire du point du vue de la personne qui va lire le code et vouloir le modifier dans 6 mois. Ici, simplement // Omit journeys as they will be populated separately in the next step est suffisant, pas besoin de comparer avec le visitedPlaces/trips car ça veut dire que le commentaire ici dépend de l'implémentation là-bas, il ne faut pas.
40b5baa to
4b421f4
Compare
ebf9609 to
799fd89
Compare
PersonFactory was using an old create pattern, we need to update it to be consistent with other base objects factories. Omit nested journeys before Person.create and cast to ExtendedPersonAttributes, matching the JourneyFactory pattern for child objects built separately. Why omit journeys: journeys are a nested child collection stored on the person's attributes, not a Person constructor input. Just like visitedPlaces/trips are omitted before Journey.create in JourneyFactory, journeys must be created individually (via populateJourneysForPerson) once the person itself exists, so that errors for each journey are tracked separately instead of failing the whole Person.create call. Also move the populateJourneysForPerson + setupWorkAndSchoolPlaces calls from SurveyObjectsFactory into populatePersonsForHousehold, right after a person is successfully created. This matches the pattern already used by JourneyFactory, which calls populateVisitedPlacesForJourney and populateTripsForJourney directly in its own isOk block instead of leaving that orchestration to the caller. Code written by Cursor Composer 2.5 and reviewed by @kaligrafy
799fd89 to
ec4d61f
Compare
|
@coderabbitai review |
✅ Action performedReview finished.
|
greenscientist
left a comment
There was a problem hiding this comment.
I guess I'll accept.
I feel that the omitting should be handled by the create function directly, maybe we some flags passed to create to tell it to omit certain part.
Or maybe we should pass new journeys directly to that create function.
Just some thoughts for your considerations.
|
See #1774 1774 |
Summary
PersonFactory was using an old create pattern, we need to update it to be consistent with other base objects factories.
journeysbefore callingPerson.create, since journeys are built separately byJourneyFactoryExtendedPersonAttributes, matching the pattern used inJourneyFactoryandTripFactoryjourneysare not passed toPerson.createTest plan
yarn test --testPathPatterns='PersonFactory.test.ts'passes (7 tests)Summary by CodeRabbit
Bug Fixes
Tests