-
Notifications
You must be signed in to change notification settings - Fork 14
add more enrollment durations in data dropdown; add default total option #2755
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
base: experiment-design-refresh
Are you sure you want to change the base?
add more enrollment durations in data dropdown; add default total option #2755
Conversation
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.
Pull request overview
This PR adds more enrollment duration options to the data dropdown in the enrollment over time component and introduces a new "Total" option as the default selection. The changes include adding LAST_TWO_WEEKS, LAST_ONE_MONTH, and TOTAL date ranges to both the frontend and backend, with backend logic to handle yearly aggregation for older experiments.
Key Changes
- Added three new date range options:
LAST_TWO_WEEKS,LAST_ONE_MONTH, andTOTALto theDATE_RANGEenum - Changed the default date filter from
LAST_SEVEN_DAYStoTOTALin the enrollment over time component - Implemented backend logic to dynamically determine date granularity (monthly vs yearly) based on experiment age
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| types/src/Experiment/enums.ts | Added new date range enum values for two weeks, one month, and total |
| frontend/projects/upgrade/src/app/features/dashboard/home/components/enrollment-over-time/enrollment-over-time.component.ts | Updated component to support new date ranges, added effectiveDateFilter logic, and changed default filter to TOTAL |
| frontend/projects/upgrade/src/app/core/experiments/store/experiments.model.ts | Added properties for new date ranges to the graph info interface |
| frontend/projects/upgrade/src/app/core/experiments/store/experiments.selector.spec.ts | Added test data for new date ranges |
| frontend/projects/upgrade/src/app/core/experiments/store/experiments.reducer.spec.ts | Added test data for new date ranges |
| backend/packages/Upgrade/src/api/services/AnalyticsService.ts | Added logic to handle new date ranges and calculate experiment age for appropriate data granularity |
| backend/packages/Upgrade/src/api/repositories/AnalyticsRepository.ts | Updated repository to support new date ranges and TOTAL option without date filtering |
| backend/packages/Upgrade/src/api/controllers/AnalyticsController.ts | Updated API documentation to include new date range options |
Comments suppressed due to low confidence (2)
frontend/projects/upgrade/src/app/core/experiments/store/experiments.model.ts:305
- The
IExperimentGraphInfointerface is missing theTOTALproperty. This interface should include all possibleDATE_RANGEenum values to maintain consistency and avoid potential runtime errors when accessing graph data for the TOTAL range.
Add the missing property:
export interface IExperimentGraphInfo {
[DATE_RANGE.LAST_SEVEN_DAYS]: IEnrollmentStatByDate[];
[DATE_RANGE.LAST_TWO_WEEKS]: IEnrollmentStatByDate[];
[DATE_RANGE.LAST_ONE_MONTH]: IEnrollmentStatByDate[];
[DATE_RANGE.LAST_THREE_MONTHS]: IEnrollmentStatByDate[];
[DATE_RANGE.LAST_SIX_MONTHS]: IEnrollmentStatByDate[];
[DATE_RANGE.LAST_TWELVE_MONTHS]: IEnrollmentStatByDate[];
[DATE_RANGE.TOTAL]: IEnrollmentStatByDate[];
}export interface IExperimentGraphInfo {
[DATE_RANGE.LAST_SEVEN_DAYS]: IEnrollmentStatByDate[];
[DATE_RANGE.LAST_TWO_WEEKS]: IEnrollmentStatByDate[];
[DATE_RANGE.LAST_ONE_MONTH]: IEnrollmentStatByDate[];
[DATE_RANGE.LAST_THREE_MONTHS]: IEnrollmentStatByDate[];
[DATE_RANGE.LAST_SIX_MONTHS]: IEnrollmentStatByDate[];
[DATE_RANGE.LAST_TWELVE_MONTHS]: IEnrollmentStatByDate[];
}
frontend/projects/upgrade/src/app/features/dashboard/home/components/enrollment-over-time/enrollment-over-time.component.ts:261
- The
applyExperimentFilterfunction callssetEffectiveDateFilter()and then passesthis.selectedDateFiltertosetGraphRange(). However, whenselectedDateFilterisTOTAL, the backend needs to receive theeffectiveDateFilter(which could beLAST_ONE_MONTH,LAST_TWELVE_MONTHS, orTOTALdepending on experiment age) to properly query the data with the correct time granularity.
The function should pass this.effectiveDateFilter instead:
this.experimentService.setGraphRange(
this.effectiveDateFilter,
this.experiment.id,
-new Date().getTimezoneOffset()
); this.experimentService.setGraphRange(
this.selectedDateFilter,
this.experiment.id,
-new Date().getTimezoneOffset()
);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...pp/features/dashboard/home/components/enrollment-over-time/enrollment-over-time.component.ts
Show resolved
Hide resolved
...pp/features/dashboard/home/components/enrollment-over-time/enrollment-over-time.component.ts
Outdated
Show resolved
Hide resolved
backend/packages/Upgrade/src/api/repositories/AnalyticsRepository.ts
Outdated
Show resolved
Hide resolved
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.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (2)
frontend/projects/upgrade/src/app/core/experiments/store/experiments.reducer.spec.ts:212
- The test data is missing the
TOTALproperty for thegraphInfoobject. Since theIExperimentGraphInfointerface should include all DATE_RANGE options, test data should also include theTOTALproperty to maintain consistency.
Add the missing property:
previousState.graphInfo = {
[DATE_RANGE.LAST_SEVEN_DAYS]: [],
[DATE_RANGE.LAST_TWO_WEEKS]: [],
[DATE_RANGE.LAST_ONE_MONTH]: [],
[DATE_RANGE.LAST_THREE_MONTHS]: [],
[DATE_RANGE.LAST_SIX_MONTHS]: [],
[DATE_RANGE.LAST_TWELVE_MONTHS]: [],
[DATE_RANGE.TOTAL]: [],
}; previousState.graphInfo = {
[DATE_RANGE.LAST_SEVEN_DAYS]: [],
[DATE_RANGE.LAST_TWO_WEEKS]: [],
[DATE_RANGE.LAST_ONE_MONTH]: [],
[DATE_RANGE.LAST_THREE_MONTHS]: [],
[DATE_RANGE.LAST_SIX_MONTHS]: [],
[DATE_RANGE.LAST_TWELVE_MONTHS]: [],
};
frontend/projects/upgrade/src/app/core/experiments/store/experiments.model.ts:305
- The
IExperimentGraphInfointerface is missing theTOTALproperty that corresponds to the newly addedDATE_RANGE.TOTALenum value. This interface should include all date range options to maintain type consistency.
Add the missing property:
export interface IExperimentGraphInfo {
[DATE_RANGE.LAST_SEVEN_DAYS]: IEnrollmentStatByDate[];
[DATE_RANGE.LAST_TWO_WEEKS]: IEnrollmentStatByDate[];
[DATE_RANGE.LAST_ONE_MONTH]: IEnrollmentStatByDate[];
[DATE_RANGE.LAST_THREE_MONTHS]: IEnrollmentStatByDate[];
[DATE_RANGE.LAST_SIX_MONTHS]: IEnrollmentStatByDate[];
[DATE_RANGE.LAST_TWELVE_MONTHS]: IEnrollmentStatByDate[];
[DATE_RANGE.TOTAL]: IEnrollmentStatByDate[];
}export interface IExperimentGraphInfo {
[DATE_RANGE.LAST_SEVEN_DAYS]: IEnrollmentStatByDate[];
[DATE_RANGE.LAST_TWO_WEEKS]: IEnrollmentStatByDate[];
[DATE_RANGE.LAST_ONE_MONTH]: IEnrollmentStatByDate[];
[DATE_RANGE.LAST_THREE_MONTHS]: IEnrollmentStatByDate[];
[DATE_RANGE.LAST_SIX_MONTHS]: IEnrollmentStatByDate[];
[DATE_RANGE.LAST_TWELVE_MONTHS]: IEnrollmentStatByDate[];
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
No description provided.