Skip to content

Cycle round-robin per experiment in within-subject experiment#3197

Open
bcb37 wants to merge 4 commits into
devfrom
fix/cycle-round-robin-per-experiment
Open

Cycle round-robin per experiment in within-subject experiment#3197
bcb37 wants to merge 4 commits into
devfrom
fix/cycle-round-robin-per-experiment

Conversation

@bcb37

@bcb37 bcb37 commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 adjusts how repeated-enrollment counts are computed and passed into within-subject assignment logic, with the goal of influencing round-robin cycling behavior for within-subject experiments.

Changes:

  • Replaces per-decision-point repeated enrollment lookup with a single aggregated repeatedEnrollmentCount value.
  • Flattens collection of active decision points via flatMap and sums counts from RepeatedEnrollmentRepository.getRepeatedEnrollmentCount(...).
  • Updates mapDecisionPoints(...) to take a numeric repeatedEnrollmentCount instead of an array of per-decision-point counts.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/backend/src/api/services/ExperimentAssignmentService.ts Outdated
Comment thread packages/backend/src/api/services/ExperimentAssignmentService.ts Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

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

Comment thread packages/backend/src/api/services/ExperimentAssignmentService.ts Outdated
Comment on lines +22 to +26
.leftJoin('repeatedEnrollment.individualEnrollment', 'ie')
.leftJoin('ie.experiment', 'experiment')
.where('ie.userId = :userId', { userId })
.andWhere('ie.partitionId IN (:...decisionPointsIds)', { decisionPointsIds })
.groupBy('ie.userId , ie.partitionId , ie.id')
.andWhere('ie.experimentId IN (:...experimentIds)', { experimentIds })
.groupBy('ie.userId , ie.experimentId , ie.id')
Comment on lines 435 to 438
repeatedEnrollmentCounts = await this.repeatedEnrollmentRepository.getRepeatedEnrollmentCount(
userId,
allWithinSubjectDecisionPoints.map((dp) => dp.id),
filteredWithinSubjectExperiments.map((experiment) => experiment.id),
logger
bcb37 and others added 2 commits June 26, 2026 16:38
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.

2 participants