feat: add data migration to sync DiscussionsConfiguration with modulestore tab.is_hidden#38294
feat: add data migration to sync DiscussionsConfiguration with modulestore tab.is_hidden#38294Anas12091101 wants to merge 1 commit intoopenedx:masterfrom
Conversation
|
Thanks for the pull request, @Anas12091101! This repository is currently maintained by Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review. 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. DetailsWhere can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources: When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
| CourseAppStatus.objects.filter( | ||
| course_key=course_key, | ||
| app_id="discussion", | ||
| ).exclude( | ||
| enabled=expected_enabled, | ||
| ).update(enabled=expected_enabled) |
There was a problem hiding this comment.
The CourseAppStatus model is what the Pages & Resources MFE actually reads to determine whether the Discussion app shows as "Enabled" or "Disabled". When the API endpoint /api/course_apps/v1/apps/{course_id} is called, it first checks CourseAppStatus.enabled for the "discussion" app and only falls back to DiscussionsConfiguration.is_enabled()( if no row exists. So updating DiscussionsConfiguration.enabled alone is not enough; if a CourseAppStatus row already exists with enabled=True, the MFE will still show the discussion tab as enabled regardless of what DiscussionsConfiguration says. This is why we update both models in the migration to ensure the UI reflects the actual tab visibility from the course structure.
There was a problem hiding this comment.
Wow, there are so many layers 😵
@Anas12091101 When a course is imported, does CourseAppStatus.enabled get updated from the modulestore tab's is_hidden state, like you did for DiscussionConfiguration.enabled? (If not, then am I correct to understand that this migration would only be a one-time fix for existing CourseAppStatuses, and the issue would continue for future imports?)
…store tab.is_hidden
ff22569 to
f07de7f
Compare
|
|
||
|
|
||
| def sync_enabled_from_course_overview_tab(apps, schema_editor): | ||
| CourseOverviewTab = apps.get_model("course_overviews", "CourseOverviewTab") |
There was a problem hiding this comment.
Glad that the CourseOverviewTab model works! Thanks for the suggestion, Dave.
| CourseAppStatus.objects.filter( | ||
| course_key=course_key, | ||
| app_id="discussion", | ||
| ).exclude( | ||
| enabled=expected_enabled, | ||
| ).update(enabled=expected_enabled) |
There was a problem hiding this comment.
Wow, there are so many layers 😵
@Anas12091101 When a course is imported, does CourseAppStatus.enabled get updated from the modulestore tab's is_hidden state, like you did for DiscussionConfiguration.enabled? (If not, then am I correct to understand that this migration would only be a one-time fix for existing CourseAppStatuses, and the issue would continue for future imports?)
Description
We introduced a fix in #38084 to synchronize DiscussionsConfiguration.enabled (DB) with tab.is_hidden (modulestore) during course imports. While this resolves the issue for newly imported courses, existing courses that are currently out of sync still need to be updated so that course authors see the correct values.
This PR adds a data migration that reads each course's discussion tab from
CourseOverviewTab(a DB-level cache of modulestore tabs) and updates bothDiscussionsConfiguration.enabledandCourseAppStatus.enabledto match (enabled = NOT is_hidden). Only out-of-sync rows are updated. The migration usesCourseOverviewTabinstead of the modulestore directly to avoid performance issues at scale.Useful information to include:
changes.
Supporting information
#38084 (comment)
Testing instructions
Visit the
Pages and Resourcespage in the authoring MFE and verify that the discussion configuration is unsyncedRun the migration:
Deadline
"None"
Other information
Include anything else that will help reviewers and consumers understand the change.