Skip to content

Return cohortDefinitionId from cohort materialization response - #3044

Open
p-hoffmann wants to merge 3 commits into
developfrom
p-hoffmann/cohort-materialization-return-id
Open

Return cohortDefinitionId from cohort materialization response#3044
p-hoffmann wants to merge 3 commits into
developfrom
p-hoffmann/cohort-materialization-return-id

Conversation

@p-hoffmann

Copy link
Copy Markdown
Member

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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.data so callers can access the returned cohort id.
  • Update the Save Cohort modal to read cohortDefinitionId from 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.
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.

2 participants