Skip to content

fix: seed users and refresh stats for all courses with threads - #657

Merged
ahmed-arb merged 1 commit into
develop-teakfrom
ahmed-arb/reconnect-refresh-all-courses-with-threads
Jul 1, 2026
Merged

fix: seed users and refresh stats for all courses with threads#657
ahmed-arb merged 1 commit into
develop-teakfrom
ahmed-arb/reconnect-refresh-all-courses-with-threads

Conversation

@ahmed-arb

Copy link
Copy Markdown
Collaborator

Follow-up to the reconnect_legacy_discussion_threads command. That command returned early for courses whose discussion topics were already correctly linked ("healthy"), so it seeded ForumUser records 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 does ForumUser.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 ForumUser records 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 reports stats-refreshed (or would-refresh-stats in dry-run) instead of healthy, 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

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
ahmed-arb merged commit 5c7c953 into develop-teak Jul 1, 2026
9 of 11 checks passed
@ahmed-arb
ahmed-arb deleted the ahmed-arb/reconnect-refresh-all-courses-with-threads branch July 3, 2026 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant