Skip to content

Conversation

@bcb37
Copy link
Collaborator

@bcb37 bcb37 commented Nov 21, 2025

No description provided.

Copilot finished reviewing on behalf of bcb37 November 21, 2025 17:39
Copy link
Contributor

Copilot AI left a 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, and TOTAL to the DATE_RANGE enum
  • Changed the default date filter from LAST_SEVEN_DAYS to TOTAL in 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 IExperimentGraphInfo interface is missing the TOTAL property. This interface should include all possible DATE_RANGE enum 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 applyExperimentFilter function calls setEffectiveDateFilter() and then passes this.selectedDateFilter to setGraphRange(). However, when selectedDateFilter is TOTAL, the backend needs to receive the effectiveDateFilter (which could be LAST_ONE_MONTH, LAST_TWELVE_MONTHS, or TOTAL depending 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.

@bcb37 bcb37 requested a review from Copilot November 21, 2025 21:27
Copilot finished reviewing on behalf of bcb37 November 21, 2025 21:30
Copy link
Contributor

Copilot AI left a 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 TOTAL property for the graphInfo object. Since the IExperimentGraphInfo interface should include all DATE_RANGE options, test data should also include the TOTAL property 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 IExperimentGraphInfo interface is missing the TOTAL property that corresponds to the newly added DATE_RANGE.TOTAL enum 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.

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.

Add More Options to the Enrollment Time Dropdown in the Experiment Data Tab

2 participants