Skip to content

Feature/rewards summary direct query#2994

Open
danoswaltCL wants to merge 4 commits intodevfrom
feature/rewards-summary-direct-query
Open

Feature/rewards summary direct query#2994
danoswaltCL wants to merge 4 commits intodevfrom
feature/rewards-summary-direct-query

Conversation

@danoswaltCL
Copy link
Collaborator

@danoswaltCL danoswaltCL commented Mar 4, 2026

#2955

this adds functionality to directly query the mooclet "value" table to count rewards instead of using the currentPosteriors, which is always stale and a little confusing in the UI.

The display remains the same, and we are able to use existing infrastructure to do so without making changes to the mooclet code. 👍

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

Adds a “rewards summary” data path that queries Mooclet reward values directly (instead of deriving from stored posteriors) and surfaces the aggregated results in the experiment details “Reward Feedback” section.

Changes:

  • Introduces shared types for rewards summary rows and exports them from the upgrade_types package.
  • Frontend: adds API endpoint + NGRX actions/effects/reducer/selector plumbing to fetch and store rewards summaries per experiment and display them in the dashboard table.
  • Backend: adds an /experiments/mooclet-rewards/:id endpoint plus services to query Mooclet /value data and aggregate counts/success rates by condition.

Reviewed changes

Copilot reviewed 30 out of 30 changed files in this pull request and generated 13 comments.

Show a summary per file
File Description
types/src/index.ts Re-exports new rewards summary types from the Mooclet types module.
types/src/Mooclet/index.ts Adds ExperimentRewardsByCondition and ExperimentRewardsSummary shared types.
frontend/projects/upgrade/src/environments/environment-types.ts Adds getMoocletRewardsData to the API endpoints interface.
frontend/projects/upgrade/src/app/features/dashboard/experiments/pages/experiment-details-page/experiment-details-page-content/experiment-reward-feedback-section-card/ts-configurable-reward-count-table/ts-configurable-reward-count-table.component.ts Updates table input typing to consume rewards summary rows.
frontend/projects/upgrade/src/app/features/dashboard/experiments/pages/experiment-details-page/experiment-details-page-content/experiment-reward-feedback-section-card/ts-configurable-reward-count-table/ts-configurable-reward-count-table.component.html Updates success rate rendering to display the new string format.
frontend/projects/upgrade/src/app/features/dashboard/experiments/pages/experiment-details-page/experiment-details-page-content/experiment-reward-feedback-section-card/experiment-reward-feedback-section-card.component.ts Switches the section card to fetch/display rewards summary via ExperimentService.
frontend/projects/upgrade/src/app/features/dashboard/experiments/pages/experiment-details-page/experiment-details-page-content/experiment-reward-feedback-section-card/experiment-reward-feedback-section-card.component.html Binds table data/loading states to the new observables.
frontend/projects/upgrade/src/app/core/local-storage/local-storage.service.ts Adds defaults for isLoadingRewardsSummary and rewardsSummaries in stored experiment state.
frontend/projects/upgrade/src/app/core/local-storage/local-storage.service.spec.ts Updates local storage defaults tests for the new state fields.
frontend/projects/upgrade/src/app/core/experiments/store/experiments.selectors.ts Adds selectors for rewards summary data and loading state.
frontend/projects/upgrade/src/app/core/experiments/store/experiments.selector.spec.ts Adds selector tests for rewards summary + loading selectors.
frontend/projects/upgrade/src/app/core/experiments/store/experiments.reducer.ts Adds reducer handling for rewards summary fetch success/failure + loading flag.
frontend/projects/upgrade/src/app/core/experiments/store/experiments.reducer.spec.ts Adds reducer tests for rewards summary actions.
frontend/projects/upgrade/src/app/core/experiments/store/experiments.model.ts Extends ExperimentState with rewards summary storage and loading flag; removes old posteriors table row type.
frontend/projects/upgrade/src/app/core/experiments/store/experiments.effects.ts Adds effect to call API and dispatch rewards summary success/failure actions.
frontend/projects/upgrade/src/app/core/experiments/store/experiments.effects.spec.ts Adds effect tests for the rewards summary fetch flow.
frontend/projects/upgrade/src/app/core/experiments/store/experiments.actions.ts Adds NGRX actions for rewards summary fetch flow.
frontend/projects/upgrade/src/app/core/experiments/experiments.service.ts Adds service methods to dispatch fetch action and select rewards summary/loading state.
frontend/projects/upgrade/src/app/core/experiments/experiments.data.service.ts Adds HTTP call to /experiments/mooclet-rewards/:id.
frontend/projects/upgrade/src/app/core/api-endpoints.constants.ts Adds /experiments/mooclet-rewards constant.
clientlibs/js/quickTest.ts Updates local quick test values for reward testing.
backend/rest-client-vscode/MoocletAPI.http Updates Rest Client examples and adds a rewards query example.
backend/packages/Upgrade/test/unit/services/MoocletRewardsService.test.ts Adds unit tests for new rewards summary aggregation methods.
backend/packages/Upgrade/test/unit/services/MoocletDataService.test.ts Adds unit tests for new Mooclet rewards query method.
backend/packages/Upgrade/test/unit/controllers/mocks/MoocletRewardsServiceMock.ts Adds controller mock to support new endpoint tests.
backend/packages/Upgrade/test/unit/controllers/ExperimentController.test.ts Wires in the new rewards service mock for controller tests.
backend/packages/Upgrade/src/types/Mooclet.ts Adds paginated response type and request body for reward count query.
backend/packages/Upgrade/src/api/services/MoocletRewardsService.ts Adds rewards summary fetch + aggregation logic by condition/version mapping.
backend/packages/Upgrade/src/api/services/MoocletDataService.ts Adds getRewardsForExperiment to query Mooclet /value data.
backend/packages/Upgrade/src/api/controllers/ExperimentController.ts Adds /experiments/mooclet-rewards/:id endpoint behind env.mooclets.enabled.

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

@danoswaltCL danoswaltCL force-pushed the feature/rewards-summary-direct-query branch 3 times, most recently from 23188b3 to bc27a8c Compare March 5, 2026 14:17
@CarnegieLearningWeb CarnegieLearningWeb deleted a comment from Copilot AI Mar 5, 2026
@danoswaltCL danoswaltCL force-pushed the feature/rewards-summary-direct-query branch from bc27a8c to 137c1a4 Compare March 5, 2026 14:30
@danoswaltCL danoswaltCL force-pushed the feature/rewards-summary-direct-query branch from 137c1a4 to f3b5088 Compare March 5, 2026 14:31
moocletRewardsResponse: MoocletPaginatedResponse<MoocletValueResponseDetails>,
logger: UpgradeLogger
): Promise<ExperimentRewardsSummary> {
const rewards: MoocletValueResponseDetails[] = moocletRewardsResponse.results;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Based on the type, this is a paginated response? Could it ever be possible that the results in moocletRewardsResponse.results will be an incomplete data set of only the first [page_length] results?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

i'll re-look at this, I was thinking I could configure the mooclet server to ignore page max limitations but that doesn't seem to work the way i hoped. i guess will need to have it iterate until all are fetched.

@bcb37 bcb37 self-requested a review March 5, 2026 21:31
Copy link
Collaborator

@bcb37 bcb37 left a comment

Choose a reason for hiding this comment

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

This looks good and seems to work. Just one question.

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