fix: simplify unlinked-learner exclusion in the Learner Progress Report - #704
Conversation
Replaces the Q(is_linked=True) | Q(enterprise_user__isnull=True, is_consent_granted=False) filter with a plain .exclude() on is_linked=False. Equivalent for every case in current data (both excluded genuinely-unlinked learners and include non-DSC enrollments identically), with simpler code at the cost of an explicit guard against the theoretical case of a NULL enterprise_user with consent granted -- not expected to occur given current warehouse ETL behavior. [ENT-12136]
ebd5bd0 to
97091ae
Compare
| ).exclude( | ||
| enterprise_user__is_linked=False, |
There was a problem hiding this comment.
Have we confirmed that is_consent_granted=False users also have is_linked=True? The previous implementation seemed to be operating under a different assumption.
There was a problem hiding this comment.
The main difference functionally between the old query and the new query is that the old query guarded against showing records where enterprise_user is null and is_consent_granted is True. I queried the production database, however, and no such records exist. As such, this simplification shouldn't cause regressions.
| ).exclude( | ||
| enterprise_user__is_linked=False, |
There was a problem hiding this comment.
The main difference functionally between the old query and the new query is that the old query guarded against showing records where enterprise_user is null and is_consent_granted is True. I queried the production database, however, and no such records exist. As such, this simplification shouldn't cause regressions.
JIRA: https://2u-internal.atlassian.net/browse/ENT-12136
Summary
Follow-up to #703. Simplifies the queryset filter in
EnterpriseLearnerEnrollmentViewSet.get_queryset():Test plan
test_get_queryset_adds_placeholder_metadata_columnsmock assertions for the.exclude()call.test_list_includes_non_consented_enrollments_with_no_enterprise_userandtest_list_excludes_non_consented_enrollments_of_genuinely_unlinked_learners(from fix: keep non-DSC enrollments visible in the Learner Progress Report #703) both still pass unchanged, confirming behavior is identical for the ticket's real scenarios.