-
Notifications
You must be signed in to change notification settings - Fork 6
PS-441 fix for phase predecessor calculations on update #35
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -91,6 +91,7 @@ class ChallengePhaseHelper { | |
| timelineTemplateId | ||
| ); | ||
| const { phaseDefinitionMap } = await this.getPhaseDefinitionsAndMap(); | ||
| const challengePhaseIds = new Set(_.map(challengePhases, "phaseId")); | ||
|
|
||
| // Ensure deterministic processing order based on the timeline template sequence | ||
| // DB returns phases ordered by dates, which can cause "fixedStartDate" logic below | ||
|
|
@@ -107,9 +108,18 @@ class ChallengePhaseHelper { | |
| const phaseFromTemplate = timelineTemplateMap.get(phase.phaseId); | ||
| const phaseDefinition = phaseDefinitionMap.get(phase.phaseId); | ||
| const newPhase = _.find(newPhases, (p) => p.phaseId === phase.phaseId); | ||
| const templatePredecessor = _.get(phaseFromTemplate, "predecessor"); | ||
| // Prefer template predecessor only when that phase exists on the challenge, otherwise keep the stored link. | ||
| const resolvedPredecessor = _.isNil(phaseFromTemplate) | ||
| ? phase.predecessor | ||
| : _.isNil(templatePredecessor) | ||
| ? null | ||
| : challengePhaseIds.has(templatePredecessor) | ||
| ? templatePredecessor | ||
| : phase.predecessor; | ||
| const updatedPhase = { | ||
| ...phase, | ||
| predecessor: phaseFromTemplate && phaseFromTemplate.predecessor, | ||
| predecessor: resolvedPredecessor, | ||
| description: phaseDefinition.description, | ||
| }; | ||
| if (updatedPhase.name === "Post-Mortem") { | ||
|
|
@@ -157,6 +167,9 @@ class ChallengePhaseHelper { | |
| const predecessorPhase = _.find(updatedPhases, { | ||
| phaseId: phase.predecessor, | ||
| }); | ||
| if (_.isNil(predecessorPhase)) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ |
||
| continue; | ||
| } | ||
| if (phase.name === "Iterative Review") { | ||
| if (!iterativeReviewSet) { | ||
| if (_.isNil(phase.actualStartDate)) { | ||
|
|
||
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.
[💡
performance]Using
_.mapto create aSetofphaseIds is efficient for lookups, but ensure thatchallengePhasesis not excessively large, as this could impact performance. Consider profiling if performance issues arise.