Skip to content

feat: B2C Subscription Inclusion Flag for Program Algolia Reindex#63

Open
skumargupta83 wants to merge 2 commits into
masterfrom
SUBS/ENHA-820-1
Open

feat: B2C Subscription Inclusion Flag for Program Algolia Reindex#63
skumargupta83 wants to merge 2 commits into
masterfrom
SUBS/ENHA-820-1

Conversation

@skumargupta83

Copy link
Copy Markdown

No description provided.

Copilot AI review requested due to automatic review settings July 24, 2026 05:51

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the Algolia proxy model layer to expose the b2c_subscription_inclusion flag for indexing (with accompanying test coverage), aligning course/program Algolia representations with the underlying product models.

Changes:

  • Added a b2c_subscription_inclusion accessor on AlgoliaBasicModelFieldsMixin and removed the prior custom getter/setter override on AlgoliaProxyCourse.
  • Added new tests intended to validate b2c_subscription_inclusion behavior for course and program Algolia proxy models.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
course_discovery/apps/course_metadata/algolia_models.py Adjusts how b2c_subscription_inclusion is surfaced on Algolia proxy models/mixins.
course_discovery/apps/course_metadata/tests/test_algolia_models.py Adds tests covering b2c_subscription_inclusion for course/program Algolia proxy objects.
Comments suppressed due to low confidence (2)

course_discovery/apps/course_metadata/tests/test_algolia_models.py:982

  • Same issue as the previous test: AlgoliaProxyCourse(product=course) is not a supported constructor and will raise TypeError. Build an AlgoliaProxyCourse instance via AlgoliaProxyCourseFactory and assert on its persisted field value instead.
        course = CourseFactory(b2c_subscription_inclusion=False)
        proxy_course = AlgoliaProxyCourse(product=course)
        self.assertFalse(proxy_course.b2c_subscription_inclusion)

course_discovery/apps/course_metadata/tests/test_algolia_models.py:994

  • Same issue as the previous program test: AlgoliaProxyProgram(product=program) is not a supported constructor. Create the proxy program via AlgoliaProxyProgramFactory and assert against the model field value.
        program = ProgramFactory(b2c_subscription_inclusion=False)
        proxy_program = AlgoliaProxyProgram(product=program)
        self.assertFalse(proxy_program.b2c_subscription_inclusion)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +229 to +236
@property
def b2c_subscription_inclusion(self):
"""Return the b2c_subscription_inclusion value from the underlying product instance."""
# If this is a wrapped product (using the product attribute), get from product
if hasattr(self, 'product') and self.product is not None:
return getattr(self.product, 'b2c_subscription_inclusion', False)
# Otherwise get from the instance itself, avoiding infinite recursion by checking __dict__
return self.__dict__.get('b2c_subscription_inclusion', False)
Comment on lines +974 to +976
course = CourseFactory(b2c_subscription_inclusion=True)
proxy_course = AlgoliaProxyCourse(product=course)
self.assertTrue(proxy_course.b2c_subscription_inclusion)
Comment on lines +986 to +988
program = ProgramFactory(b2c_subscription_inclusion=True)
proxy_program = AlgoliaProxyProgram(product=program)
self.assertTrue(proxy_program.b2c_subscription_inclusion)
Copilot AI review requested due to automatic review settings July 24, 2026 06:08

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

course_discovery/apps/course_metadata/algolia_models.py:236

  • AlgoliaBasicModelFieldsMixin.b2c_subscription_inclusion is unlikely to be used by AlgoliaProxyCourse/AlgoliaProxyProgram because both Course and Program define a concrete b2c_subscription_inclusion model field (so attribute resolution will hit the field descriptor on the base model before this mixin). This makes the added property effectively dead code and can be misleading; it also risks shadowing the field if the inheritance order ever changes.

Consider removing this mixin property (or moving any special handling to the actual wrapper class that uses self.product).

        # If this is a wrapped product (using the product attribute), get from product
        if hasattr(self, 'product') and self.product is not None:
            return getattr(self.product, 'b2c_subscription_inclusion', False)
        # Otherwise get from the instance itself, avoiding infinite recursion by checking __dict__
        return self.__dict__.get('b2c_subscription_inclusion', False)

Comment on lines +984 to +988
def test_b2c_subscription_inclusion_true_for_program(self):
"""Verify b2c_subscription_inclusion is True for a program when set."""
program = ProgramFactory(b2c_subscription_inclusion=True)
proxy_program = AlgoliaProxyProgram.objects.get(pk=program.pk)
self.assertTrue(proxy_program.b2c_subscription_inclusion)
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