-
Notifications
You must be signed in to change notification settings - Fork 4
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
base: main
Are you sure you want to change the base?
SONIC-704: Add CT discount availed check for outline tab #303
Conversation
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
|
||
discounted_orders = self.base_client.orders.query( | ||
where=[ | ||
"customerEmail=:email", |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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'} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
mock_orders = { | ||
"total": 1, | ||
"results": [ | ||
{ | ||
"discountCodes": [ | ||
{ | ||
"discountCode": { | ||
"obj": { | ||
"code": 'another-code' | ||
} | ||
} | ||
} | ||
] | ||
} | ||
] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can make it a constant since its been repeated across tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both mock_orders have different code values hence, I didn't make it a constant
Merge checklist:
Check off if complete or not applicable:
Post-merge: