-
Notifications
You must be signed in to change notification settings - Fork 15
Use new 'repeated_enrollment' table for within-subject experiments #2559
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
Merged
bcb37
merged 4 commits into
dev
from
feature/2505-simplify-within-subjects-functionality
Jul 22, 2025
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
3f8b255
Use new 'repeated_enrollment' table for within-subject experiments
bcb37 ebf335a
Update backend/packages/Upgrade/test/integration/ExperimentStats/With…
bcb37 e4308d8
use relative paths
bcb37 45c51da
fix postgres text case return values
bcb37 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
backend/packages/Upgrade/src/api/models/RepeatedEnrollment.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| import { Column, Entity, Index, ManyToOne, PrimaryGeneratedColumn } from 'typeorm'; | ||
| import { BaseModel } from './base/BaseModel'; | ||
| import { IndividualEnrollment } from '../models/IndividualEnrollment'; | ||
| import { ExperimentCondition } from '../models/ExperimentCondition'; | ||
|
|
||
| @Entity() | ||
| export class RepeatedEnrollment extends BaseModel { | ||
| @PrimaryGeneratedColumn() | ||
| public id: string; | ||
|
|
||
| @Index() | ||
| @ManyToOne(() => ExperimentCondition, { onDelete: 'CASCADE' }) | ||
| public condition: ExperimentCondition; | ||
|
|
||
| @Column({ name: 'conditionId', nullable: true }) | ||
| public conditionId?: string; | ||
|
|
||
| @Column({ | ||
| nullable: true, | ||
| }) | ||
| public uniquifier: string | null; | ||
|
|
||
| @Index() | ||
| @ManyToOne(() => IndividualEnrollment, { onDelete: 'CASCADE' }) | ||
| public individualEnrollment: IndividualEnrollment; | ||
|
|
||
| @Column({ name: 'individualEnrollmentId', nullable: true }) | ||
| public individualEnrollmentId?: string; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
backend/packages/Upgrade/src/api/repositories/RepeatedEnrollmentRepository.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| import { RepeatedEnrollment } from '../models/RepeatedEnrollment'; | ||
| import { Repository } from 'typeorm'; | ||
| import { EntityRepository } from '../../typeorm-typedi-extensions'; | ||
| import { UpgradeLogger } from '../../lib/logger/UpgradeLogger'; | ||
| import repositoryError from './utils/repositoryError'; | ||
|
|
||
| export interface RepeatedEnrollmentDataCount { | ||
| userId: string; | ||
| decisionPointId: string; | ||
| count: number; | ||
| } | ||
| @EntityRepository(RepeatedEnrollment) | ||
| export class RepeatedEnrollmentRepository extends Repository<RepeatedEnrollment> { | ||
| public async getRepeatedEnrollmentCount( | ||
| userId: string, | ||
| decisionPointsIds: string[], | ||
| logger: UpgradeLogger | ||
| ): Promise<RepeatedEnrollmentDataCount[]> { | ||
| const result = await this.createQueryBuilder('repeatedEnrollment') | ||
| .select(['ie.userId as "userId"', 'ie.partitionId as "decisionPointId"']) | ||
| .addSelect('COUNT(*) as count') | ||
| .leftJoin('repeatedEnrollment.individualEnrollment', 'ie') | ||
| .where('ie.userId = :userId', { userId }) | ||
| .andWhere('ie.partitionId IN (:...decisionPointsIds)', { decisionPointsIds }) | ||
| .groupBy('ie.userId , ie.partitionId , ie.id') | ||
|
bcb37 marked this conversation as resolved.
|
||
| .getRawMany() | ||
| .catch((errorMsg: any) => { | ||
| const errorMsgString = repositoryError( | ||
| 'RepeatedEnrollmentRepository', | ||
| 'getRepeatedEnrollmentCount', | ||
| {}, | ||
| errorMsg | ||
| ); | ||
| logger.error(errorMsg); | ||
| throw errorMsgString; | ||
| }); | ||
| return result; | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.