fix: seed users and refresh stats for all courses with threads - #657
Merged
ahmed-arb merged 1 commit intoJul 1, 2026
Merged
Conversation
The previous version returned early for courses whose topics were already
correctly linked ("healthy"), so it never seeded ForumUser records or
recomputed stats for them. Those courses were left with an empty Learners tab
(and could still 404 on the stats endpoint if any stat-bearing user lacked a
ForumUser). Only courses that happened to have orphaned topics got the user
seeding and stats recompute.
Drop the early return so that every course with threads seeds ForumUser
records for its enrolled users and recomputes per-course stats, regardless of
whether any topics needed reconnecting. Courses with no threads still return
early. Report status as "stats-refreshed" (or "would-refresh-stats" in
dry-run) when no topic changes were needed.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
ahmed-arb
deleted the
ahmed-arb/reconnect-refresh-all-courses-with-threads
branch
July 3, 2026 12:16
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.
Follow-up to the
reconnect_legacy_discussion_threadscommand. That command returned early for courses whose discussion topics were already correctly linked ("healthy"), so it seededForumUserrecords and recomputed per-course stats only for courses that happened to have orphaned topics. Every other course that still had discussion threads was left with an empty Learners tab — and could even 404 on the stats endpoint, because the forum's per-course stats read doesForumUser.objects.get()for each stat-bearing user and the Mongo→MySQL migration never created those user records. In practice this meant the fleet-wide run fixed topics everywhere but only fixed Learners on the subset of courses with orphaned topics.This drops the early return so that any course with threads seeds
ForumUserrecords for its enrolled users and recomputes per-course stats, whether or not any topics needed reconnecting. Courses with no threads still return early and do nothing. When no topic changes were required the run now reportsstats-refreshed(orwould-refresh-statsin dry-run) instead ofhealthy, so the summary makes clear the Learners side was still handled. The command remains reversible and touches only Django-model rows plus the stats recompute.🤖 Generated with Claude Code