Return cohortDefinitionId from cohort materialization response - #3044
Open
p-hoffmann wants to merge 3 commits into
Open
Return cohortDefinitionId from cohort materialization response#3044p-hoffmann wants to merge 3 commits into
p-hoffmann wants to merge 3 commits into
Conversation
p-hoffmann
requested review from
LSriragavan,
brandantck,
jerome-ng and
khairul-syazwan
as code owners
August 4, 2026 06:21
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the cohort materialization flow so the backend returns the cohortDefinitionId directly in the materialization response, allowing the UI to avoid deriving it indirectly from refreshed bookmark/cohort lists.
Changes:
- Return
{ message, cohortDefinitionId }from the analytics-svc cohort materialization endpoint. - Have the Vuex action return
response.dataso callers can access the returned cohort id. - Update the Save Cohort modal to read
cohortDefinitionIdfrom the materialization response and simplify post-materialization handling.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| plugins/ui/apps/vue-mri-ui-lib/src/store/modules/collections.ts | Return response.data from onAddCohortOkButtonPress so callers can consume the materialization payload. |
| plugins/ui/apps/vue-mri-ui-lib/src/components/ShinyViewer/SaveCohortModal.vue | Use returned cohortDefinitionId instead of searching materialized cohorts; keep bookmark refresh step. |
| plugins/functions/analytics-svc/src/api/controllers/cohort.ts | Change materialization response from plain text to JSON including cohortDefinitionId. |
Comment on lines
536
to
538
| if (!cohortDefinitionId) { | ||
| throw new Error(this.getText('MRI_PA_BOOKMARK_MISSING_COHORT_DEFINITION')) | ||
| } |
Comment on lines
+540
to
+543
| this.savedCohortId = cohortDefinitionId | ||
|
|
||
| if (!materializedCohort) { | ||
| console.error('[SaveCohort] Bookmark name:', materializedBookmark.bookmarkname) | ||
| console.error('[SaveCohort] Bookmark cohortDefinitionId:', materializedBookmark.cohortDefinitionId) | ||
| console.error('[SaveCohort] Available materialized cohorts:', materializedCohorts) | ||
| throw new Error(this.getText('MRI_PA_MATERIALIZED_COHORT_NOT_FOUND')) | ||
| } | ||
| this.savingStep = 'refreshing-cohort' | ||
| await this.refreshAndFindBookmark() |
Comment on lines
+339
to
+345
| // Return the id so callers do not have to re-read it from the bookmark | ||
| // list, where it is only derived once the materialized cohort is | ||
| // visible to the reading connection. | ||
| res.status(200).json({ | ||
| message: `Cohort successfully materialized`, | ||
| cohortDefinitionId, | ||
| }); |
The dashboard read the id from getActiveCohortMaterializedId, which derives from the refreshed bookmark list and can still be missing the cohort that was just materialized, so the iframe received an empty cohortId.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.