Skip to content

fix: simplify unlinked-learner exclusion in the Learner Progress Report - #704

Merged
marlonkeating merged 2 commits into
openedx:masterfrom
sjasti-sonata-svg:fix/ent-12136-exclude-unlinked-refinement
Aug 10, 2026
Merged

fix: simplify unlinked-learner exclusion in the Learner Progress Report#704
marlonkeating merged 2 commits into
openedx:masterfrom
sjasti-sonata-svg:fix/ent-12136-exclude-unlinked-refinement

Conversation

@sjasti-sonata-svg

@sjasti-sonata-svg sjasti-sonata-svg commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

JIRA: https://2u-internal.atlassian.net/browse/ENT-12136

Summary
Follow-up to #703. Simplifies the queryset filter in EnterpriseLearnerEnrollmentViewSet.get_queryset():

 before
Q(enterprise_user__is_linked=True) | Q(enterprise_user__isnull=True, is_consent_granted=False)

 after
.exclude(enterprise_user__is_linked=False)

Test plan

  • Updated test_get_queryset_adds_placeholder_metadata_columns mock assertions for the .exclude() call.
  • Existing test_list_includes_non_consented_enrollments_with_no_enterprise_user and test_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.
  • Full suite (302 tests) passes.

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]
@sjasti-sonata-svg
sjasti-sonata-svg force-pushed the fix/ent-12136-exclude-unlinked-refinement branch from ebd5bd0 to 97091ae Compare August 6, 2026 07:38
Comment on lines +105 to +106
).exclude(
enterprise_user__is_linked=False,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +105 to +106
).exclude(
enterprise_user__is_linked=False,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@marlonkeating
marlonkeating merged commit b1bb747 into openedx:master Aug 10, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants