Skip to content

Commit

Permalink
feat: add fulfillment logging, clean up misc logging
Browse files Browse the repository at this point in the history
  • Loading branch information
iloveagent57 committed Apr 11, 2024
1 parent 7210ba0 commit 3ad1743
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
17 changes: 8 additions & 9 deletions enterprise_subsidy/apps/content_metadata/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,8 @@ def get_content_metadata(content_identifier, **kwargs):
course_details,
django_cache_timeout=CONTENT_METADATA_CACHE_TIMEOUT,
)
logger.info(
f'Fetched course details {course_details} for content_identifier {content_identifier}',
)
else:
logger.warning('Could not fetch metadata for content %s', content_identifier)
return course_details

@staticmethod
Expand All @@ -273,10 +272,10 @@ def get_content_metadata_for_customer(enterprise_customer_uuid, content_identifi
course_details,
django_cache_timeout=CONTENT_METADATA_CACHE_TIMEOUT,
)
logger.info(
'Fetched course details %s for customer %s and content_identifier %s',
course_details,
enterprise_customer_uuid,
content_identifier,
)
else:
logger.warning(
'Could not fetch metadata for customer %s, content %s',
enterprise_customer_uuid,
content_identifier,
)
return course_details
15 changes: 10 additions & 5 deletions enterprise_subsidy/apps/fulfillment/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,6 @@ def _get_enterprise_customer_data(self, transaction):
# Check if data is already cached
cached_response = request_cache(namespace=REQUEST_CACHE_NAMESPACE).get_cached_response(cache_key)
if cached_response.is_found:
logger.info(
'subsidy_record cache hit '
f'enterprise_customer_uuid={self._get_enterprise_customer_uuid(transaction)}, '
f'subsidy_uuid={transaction.uuid}'
)
return cached_response.value
# If data is not cached, fetch and cache it
enterprise_customer_uuid = str(self._get_enterprise_customer_uuid(transaction))
Expand Down Expand Up @@ -201,6 +196,11 @@ def fulfill(self, transaction):
external_reference_id = response_payload.get('orderUuid')
if not external_reference_id:
raise FulfillmentException('missing orderUuid / external_reference_id from geag')
logger.info(
'[transaction fulfillment] Fulfilled transaction %s with external reference id %s',
transaction.uuid,
external_reference_id,
)
return self._save_fulfillment_reference(transaction, external_reference_id)
except HTTPError as exc:
raise FulfillmentException(response_payload.get('errors') or geag_response.text) from exc
Expand All @@ -213,3 +213,8 @@ def cancel_fulfillment(self, external_transaction_reference):
self.get_smarter_client().cancel_enterprise_allocation(
external_transaction_reference.external_reference_id,
)
logger.info(
'[transaction fulfillment] Cancelled fulfillment for transaction %s with external reference id %s',
external_transaction_reference.transaction.uuid,
external_transaction_reference.external_reference_id,
)
4 changes: 2 additions & 2 deletions enterprise_subsidy/apps/transaction/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ def cancel_transaction_fulfillment(transaction):
to the ``audit`` mode).
"""
if transaction.state != TransactionStateChoices.COMMITTED:
logger.info(
logger.error(
"[fulfillment cancelation] %s is not committed, will not cancel fulfillment",
transaction.uuid,
)
raise TransactionFulfillmentCancelationException(
"Transaction is not committed"
)
if not transaction.fulfillment_identifier:
logger.info(
logger.error(
"[fulfillment cancelation] %s has no fulfillment uuid, will not cancel fulfillment",
transaction.uuid,
)
Expand Down

0 comments on commit 3ad1743

Please sign in to comment.