Skip to content

PM-6007 - fix phase ordering when creating challenge - #155

Merged
vas3a merged 1 commit into
developfrom
PM-6007_phase-ordering
Aug 28, 2026
Merged

PM-6007 - fix phase ordering when creating challenge#155
vas3a merged 1 commit into
developfrom
PM-6007_phase-ordering

Conversation

@vas3a

@vas3a vas3a commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator

This pull request improves the scheduling logic for challenge phases by ensuring phases are ordered and scheduled according to their predecessor relationships, regardless of the order in which they are returned from the database. It introduces a utility to order phases by dependency and updates the scheduling logic to handle missing or cyclic dependencies more robustly. Comprehensive unit tests are also added to verify the new behavior.

Phase ordering and scheduling improvements:

  • Added orderPhasesByPredecessorChain utility to sort timeline template phases so each phase follows its predecessor, ensuring correct scheduling even when database rows are unordered. Phases with unresolved or cyclic dependencies are appended last, maintaining their relative order.
  • Updated ChallengePhaseHelper.populatePhasesForChallengeCreation to use the ordered template for phase scheduling, preventing reliance on database row order.
  • Improved scheduling logic to skip phases whose predecessors are missing or unscheduled, leaving them unscheduled instead of defaulting to the current time.

Testing enhancements:

  • Added unit tests to verify that phases are scheduled correctly along the predecessor chain, regardless of input order, and that phases with unresolved predecessor chains remain unscheduled.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves challenge creation phase scheduling by removing reliance on database row order and instead scheduling phases according to their predecessor relationships, while preventing “unscheduled” phases from accidentally being scheduled at the current time.

Changes:

  • Added orderPhasesByPredecessorChain to order timeline template phases so predecessors are processed before dependents.
  • Updated populatePhasesForChallengeCreation to schedule using the ordered template and to leave phases unscheduled when their predecessor chain can’t be resolved.
  • Added unit tests covering unordered template rows and dangling predecessor chains.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
src/common/phase-helper.ts Adds dependency-based template ordering and updates creation-time scheduling to skip unresolved predecessors.
test/unit/phase-helper.test.js Adds unit tests verifying correct scheduling with unordered template rows and missing-root predecessor chains.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/common/phase-helper.ts
Comment thread src/common/phase-helper.ts
Comment thread src/common/phase-helper.ts
Comment thread test/unit/phase-helper.test.js
@vas3a
vas3a merged commit 5e1073b into develop Aug 28, 2026
7 checks passed
@vas3a
vas3a deleted the PM-6007_phase-ordering branch August 28, 2026 11:31
@vas3a
vas3a restored the PM-6007_phase-ordering branch August 28, 2026 11:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants