feat(b2b_learner_records): serve activity from the learner-records MVs - #62
Open
blarghmatey wants to merge 1 commit into
Open
blarghmatey wants to merge 1 commit into
blarghmatey wants to merge 1 commit into
Conversation
blarghmatey
added this pull request to stack #63
September 17, 2026 14:32
blarghmatey
marked this pull request as ready for review
September 17, 2026 14:32
There was a problem hiding this comment.
🔵 Needs a closer look
Deployment depends on an unmerged cross-repository MV schema change that has not yet been validated in StarRocks.
Pull request overview
Populates learner-record activity fields from the new materialized-view columns and aligns progress calculations across endpoints.
Changes:
- Projects enrollment and learner activity metrics.
- Includes tracked activity in
in_progresscalculations. - Updates tests and API documentation.
File summaries
| File | Description |
|---|---|
queries.py |
Reads activity columns and updates rollups/statuses. |
models.py |
Documents populated activity fields. |
test_learner_records.py |
Tests activity projections and calculations. |
b2b-learner-records-v1.yaml |
Updates the public API contract. |
b2b-learner-records-onepager.md |
Marks the activity model available. |
b2b-learner-records-design.md |
Documents the implemented activity pipeline. |
Review details
- Files reviewed: 6/6 changed files
- Comments generated: 0
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
ol-data-platform#2693 adds last_active_on, days_active and the three counters to mv_b2b_learner_enrollment, and last_active_on and courses_in_progress to mv_b2b_learner. The tenant projected all of them as NULL. in_progress now also counts activity. mv_b2b_learner.courses_in_progress is defined that way, so /learners and /enrollments disagree unless the completion_status CASE matches it. The counter descriptions said "distinct blocks". The MV sums per-day distinct counts, so a block used on two days counts twice. The spec also says activity doesn't move updated_since: record_updated_on can't carry a day-granular activity date without falling below the partner's cursor. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XMuwnLQwHtHuH7aECS7sf3
blarghmatey
force-pushed
the
feat/learner-records-activity
branch
from
September 17, 2026 20:01
da3b9b2 to
8625454
Compare
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.
What are the relevant tickets?
N/A. Stacked on #60. Reads the columns added in mitodl/ol-data-platform#2693.
Description (What does it do?)
Replaces the NULL placeholders for
last_active_on,days_active,videos_watched,problems_attemptedandchatbot_interactionson/enrollments, andlast_active_onandcourses_in_progresson/learners, with the MV columns.videos_watchedis the MV'svideos_played.outcomes_consent_onstays NULL.completion_status = in_progressnow means a nonzero grade or any tracked activity.mv_b2b_learner.courses_in_progressuses that definition. Without this change, the default/learnerscount and the/enrollmentsstatuses would disagree. The recomputed rollup (contract_id/include_inactive) countscourses_in_progresswith the same CASE and takesMAX(last_active_on)over the enrollments already in scope. By default that's active enrollments only, like the MV. Underinclude_inactiveit's every enrollment.Spec and model descriptions:
organization_administration_reportcountsvideos_watchedper day too, and theb2b_dashboardtotals sum it.x-data-readinesson the activity fields moves offpending-model.updated_since. A day's activity first shows up at a refresh after that day began, so a cursor derived from it would already sort below theas_ofa partner passes. Partners get activity from a full reload. Real change tracking is a separate piece of work.How can this be tested?
uv run pytest: 241 passed. New cases cover the enrollment projection and status CASE, the default learner projection, the recomputedcourses_in_progress/last_active_on, and a shared enrollment keeping its activity fields.ruff check,ruff format --checkandmypy srcare clean./enrollments(with and withoutinclude_inactive) and all three/learnerspaths against DuckDB stub tables shaped like the MVs. Statuses,last_active_onandcourses_in_progressagree across the paths. Not run on StarRocks: the columns don't exist there until #2693 merges and the MVs rebuild.Checklist:
DESC b2b_learner_records.mv_b2b_learner_enrollmentandDESC b2b_learner_records.mv_b2b_learnerlist the new columns. Until then, the queries fail on unknown columns.🤖 Generated with Claude Code
https://claude.ai/code/session_01XMuwnLQwHtHuH7aECS7sf3