-
Notifications
You must be signed in to change notification settings - Fork 11
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
feat: list_price is always populated in can_redeem #648
base: main
Are you sure you want to change the base?
Conversation
243db0e
to
0d702b3
Compare
# should not contain duplicates. | ||
matching_policy = matching_policies[0] if matching_policies else None | ||
if matching_policy: | ||
result[content_key][matching_policy].append(redemption) |
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.
I slightly refactored this function to return different mapping:
- old: dict(content_key -> dict(policy UUID -> list of redemptions)
- new: dict(content_key -> dict(policy instance -> list of redemptions)
The purpose is to avoid another DB call in downstream code to fetch the policy instance. We already pulled it into memory here in this function, so just don't discard it yet.
customer_uuid = uuid4() | ||
catalog_uuid = uuid4() |
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.
A repetitive change in this file is replacing customer_uuid with catalog_uuid. It was just wrong before.
""" | ||
Helper to isolate the task of fetching content metadata via our client. | ||
""" | ||
client = EnterpriseCatalogApiClient() | ||
try: |
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.
AFAICT, this try was useless because the else block was literally just raise exc
.
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.
Agreed, given the caller(s) of this method's parent don't seem to try/except
the re-raised exc
.
""" | ||
Helper to isolate the task of fetching content metadata via our client. | ||
""" | ||
client = EnterpriseCatalogApiClient() | ||
try: |
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.
Agreed, given the caller(s) of this method's parent don't seem to try/except
the re-raised exc
.
85e2497
to
a749cdc
Compare
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.
LGTM! Just left a handful of non-blocking nits.
enterprise_access/apps/subsidy_access_policy/content_metadata_api.py
Outdated
Show resolved
Hide resolved
a749cdc
to
1228cf5
Compare
1228cf5
to
158ea69
Compare
This basically adds a fallback branch when calculating the list_price to serialize into the can-redeem endpoint. The fallback logic relies on a net new call to enterprise-catalog to fetch content metadata containing price information agnostic of any catalog or customer.
ENT-9660
Local Dev Testing
For this manual test, I created an learner credit plan with only an assignable budget, but no assignments.
can-redeem response BEFORE commit has null list_price
can-redeem response AFTER commit has populated list_price
Stage testing plan
This URL currently returns null list_price, but it should become non-null after merging:
https://enterprise-access.stage.edx.org/api/v1/policy-redemption/enterprise-customer/b705ea3b-f2ab-484f-83b9-78cf488f1704/can-redeem/?content_key=course-v1%3Aedx%2B101010%2B1T2025
Prod testing plan
This URL currently returns null list_price, but it should become non-null after merging:
https://enterprise-access.edx.org/api/v1/policy-redemption/enterprise-customer/89cbcdd9-c3cd-4dd7-8a33-2034b50b240e/can-redeem/?content_key=course-v1%3AUniversityofCambridge%2BSUP%2B3T2025