diff --git a/enterprise_access/apps/subsidy_access_policy/content_metadata_api.py b/enterprise_access/apps/subsidy_access_policy/content_metadata_api.py index 03dc2ba8..3ef23156 100644 --- a/enterprise_access/apps/subsidy_access_policy/content_metadata_api.py +++ b/enterprise_access/apps/subsidy_access_policy/content_metadata_api.py @@ -28,11 +28,8 @@ def get_and_cache_content_metadata(enterprise_customer_uuid, content_key, timeou cache_key = versioned_cache_key('get_subsidy_content_metadata', enterprise_customer_uuid, content_key) cached_response = TieredCache.get_cached_response(cache_key) if cached_response.is_found: - logger.info('[METADATA CACHE HIT] for key %s', cache_key) return cached_response.value - logger.info('[METADATA CACHE MISS] for key %s', cache_key) - client = get_versioned_subsidy_client() try: metadata = client.get_subsidy_content_data( @@ -42,8 +39,12 @@ def get_and_cache_content_metadata(enterprise_customer_uuid, content_key, timeou except HTTPError as exc: raise exc + logger.info( + 'Fetched content metadata for customer %s and content_key %s', + enterprise_customer_uuid, + content_key, + ) TieredCache.set_all_tiers(cache_key, metadata, timeout or DEFAULT_CACHE_TIMEOUT) - logger.info('[METADATA CACHE SET] for key = %s, value = %s', cache_key, metadata) return metadata @@ -56,10 +57,8 @@ def get_and_cache_catalog_contains_content(enterprise_catalog_uuid, content_key, cache_key = versioned_cache_key('contains_content_key', enterprise_catalog_uuid, content_key) cached_response = TieredCache.get_cached_response(cache_key) if cached_response.is_found: - logger.info('[CATALOG INCLUSION CACHE HIT] for key %s', cache_key) return cached_response.value - logger.info('[CATALOG INCLUSION CACHE MISS] for key %s', cache_key) try: result = EnterpriseCatalogApiClient().contains_content_items( enterprise_catalog_uuid, @@ -68,6 +67,11 @@ def get_and_cache_catalog_contains_content(enterprise_catalog_uuid, content_key, except HTTPError as exc: raise exc + logger.info( + 'Fetched catalog inclusion for catalog %s and content_key %s. Result = %s', + enterprise_catalog_uuid, + content_key, + result, + ) TieredCache.set_all_tiers(cache_key, result, timeout or DEFAULT_CACHE_TIMEOUT) - logger.info('[CATALOG INCLUSION CACHE SET] for key = %s, value = %s', cache_key, result) return result diff --git a/enterprise_access/apps/subsidy_access_policy/subsidy_api.py b/enterprise_access/apps/subsidy_access_policy/subsidy_api.py index b58e5cf6..0671b7fe 100644 --- a/enterprise_access/apps/subsidy_access_policy/subsidy_api.py +++ b/enterprise_access/apps/subsidy_access_policy/subsidy_api.py @@ -31,10 +31,8 @@ def get_and_cache_transactions_for_learner(subsidy_uuid, lms_user_id): cache_key = learner_transaction_cache_key(subsidy_uuid, lms_user_id) cached_response = request_cache().get_cached_response(cache_key) if cached_response.is_found: - logger.info('[LEARNER TRANSACTIONS CACHE HIT] for key %s', cache_key) return cached_response.value - logger.info('[LEARNER TRANSACTIONS CACHE MISS] for key %s', cache_key) client = get_versioned_subsidy_client() response_payload = client.list_subsidy_transactions( subsidy_uuid=subsidy_uuid, @@ -54,7 +52,12 @@ def get_and_cache_transactions_for_learner(subsidy_uuid, lms_user_id): result['transactions'].extend(next_response['results']) next_page = next_response.get('next') - logger.info('[LEARNER TRANSACTIONS CACHE SET] for key %s', cache_key) + logger.info( + 'Fetched transactions for subsidy %s and lms_user_id %s. Number transactions = %s', + subsidy_uuid, + lms_user_id, + len(result['transactions']), + ) request_cache().set(cache_key, result) return result