Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SONIC-704: Add CT discount availed check for outline tab #303

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

NoyanAziz
Copy link
Contributor

Merge checklist:
Check off if complete or not applicable:

  • Documentation updated (not only docstrings)
  • Fixup commits are squashed away
  • Unit tests added/updated
  • Manual testing instructions provided
  • Noted any: Concerns, dependencies, migration issues, deadlines, tickets

Post-merge:

Copy link

github-actions bot commented Nov 27, 2024

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  commerce_coordinator/apps/commercetools
  clients.py
  pipeline.py
  commerce_coordinator/apps/commercetools/tests
  test_clients.py
  test_pipeline.py
  commerce_coordinator/apps/lms
  filters.py 86
  views.py
  commerce_coordinator/apps/lms/tests
  test_views.py
Project Total  

This report was generated by python-coverage-comment-action

result = CheckFirstTimeDiscountEligibility.run_filter(email=email)

output = {
"is_eligible": result.get('is_eligible', True)
Copy link
Contributor

Choose a reason for hiding this comment

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

should the default value be True?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For the default case, the user is going to be eligible for the first-time discount.


discounted_orders = self.base_client.orders.query(
where=[
"customerEmail=:email",
Copy link
Member

Choose a reason for hiding this comment

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

We can maybe save two API calls from being made here.
First thought on my mind was to use reference expansion which I couldn't find any for discounts. I think you have also checked this.
The second option here is to store the discount IDs themselves in settings/edx-internal.
We are already following this pattern for line_item_transition: Reference
It is not normally suggested to store the database identifiers like this but as long as the discounts remain the same, the ids/keys are going to be the same so we can minimize the extra API call here which makes more sense to me.
@shafqatfarhan to weigh in on this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For the first point, we cannot query expanded objects. For the second option, I wanted the identifiers to be consistent across all environments, which is why I suggested using discount codes, as storing IDs didn’t seem ideal. However, if we're okay with this approach, we can certainly save an API call here

"orderState=:orderState",
"discountCodes(discountCode(id in :discountIds))"
],
predicate_var={'email': email, 'discountIds': discount_ids, 'orderState': 'Complete'}
Copy link
Member

Choose a reason for hiding this comment

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

Just making sure that we don't want to cater for refunded orders here right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Refunded orders are not handled by CT itself, and if I remember correctly, we had to check for their first usage only. Correct me if I am wrong

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