fix(b2b): return blank learner names as null - #71
Merged
Merged
Conversation
Upstream stores "" rather than NULL for learners without a profile name. Those rows sorted ahead of every real name and clumped on page 1 of the contract learner directory. Normalize with NULLIF(TRIM(full_name), '') in the learner-progress and learner-records queries so they sort last with the other missing names. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2 tasks
daniellefrappier18
marked this pull request as ready for review
September 25, 2026 13:51
blarghmatey
approved these changes
Sep 25, 2026
This was referenced Sep 30, 2026
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?
Follow-up to mitodl/mit-learn#3958
Description (What does it do?)
Return blank learner names as
nullso they sort after real names, not before them.On the contract learner directory, rows with no learner name all land on page 1. The learner-progress sort is
full_name IS NULL, full_name ASC. An empty or whitespace-onlyfull_nameis not NULL, so it sorts ahead of every real name.NULLIF(TRIM(full_name), '') AS full_namein the learner-progress records query, so the existing nulls-last sort covers blank names tooenrollmentsandlearnersqueries, including the recomputed rollup'sMAX()and itsCOALESCE(l.full_name, e.full_name). Otherwise a blank name on one side could hide a real name on the other.Implementation details
_BLANK_AS_NULL_NAMEconstant, matching how both modules already keep their own copy of_COMPLETION_STATUS.Before:

Learner's with blank name were sorted to the top:
How can this be tested?
uv run pytest: all 287 tests pass, including new SQL assertions for learner-progress and for theenrollments,learners,learners?contract_id=, andlearners?include_inactive=truepaths.uv run ruff check src testspasses.GET /organizations/<org>/contracts/<contract>/learner-progress?sort=full_namefor a contract whose learners include blank names. Rows without a name come back withfull_name: nullon the last page, not at the top of page 1.🤖 Generated with Claude Code