From c09e71941f494a1865cbeb371dd9c7c09eb7d4ab Mon Sep 17 00:00:00 2001 From: John Nagro Date: Fri, 29 Sep 2023 17:13:12 +0000 Subject: [PATCH] feat: improve loggging for compare_catalog_queries_to_filters --- .../compare_catalog_queries_to_filters.py | 34 ++++++++++++------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/enterprise_catalog/apps/catalog/management/commands/compare_catalog_queries_to_filters.py b/enterprise_catalog/apps/catalog/management/commands/compare_catalog_queries_to_filters.py index 3afe2aed9..5063ee4a6 100644 --- a/enterprise_catalog/apps/catalog/management/commands/compare_catalog_queries_to_filters.py +++ b/enterprise_catalog/apps/catalog/management/commands/compare_catalog_queries_to_filters.py @@ -25,16 +25,26 @@ def handle(self, *args, **options): logger.info('compare_catalog_queries_to_filters starting...') for content_metadata in ContentMetadata.objects.filter(content_type=COURSE): for enterprise_catalog in EnterpriseCatalog.objects.all(): - discovery_included = content_metadata in enterprise_catalog.content_metadata - match = filters.does_query_match_content( - enterprise_catalog.catalog_query.content_filter, - content_metadata.json_metadata - ) - logger.info( - 'compare_catalog_queries_to_filters ' - f'enterprise_catalog={enterprise_catalog.uuid}, ' - f'content_metadata={content_metadata.content_key}, ' - f'discovery_included={discovery_included}, ' - f'filter_match={match}' - ) + try: + discovery_included = content_metadata in enterprise_catalog.content_metadata + match = filters.does_query_match_content( + enterprise_catalog.catalog_query.content_filter, + content_metadata.json_metadata + ) + does_discovery_agree_with_filter = discovery_included == match + logger.info( + 'compare_catalog_queries_to_filters ' + f'enterprise_catalog={enterprise_catalog.uuid}, ' + f'content_key={content_metadata.content_key}, ' + f'discovery_included={discovery_included}, ' + f'filter_match={match}, ' + f'does_discovery_agree_with_filter={does_discovery_agree_with_filter}' + ) + except Exception: + logger.exception( + 'compare_catalog_queries_to_filters ' + 'filter exception ' + f'enterprise_catalog={enterprise_catalog.uuid}, ' + f'content_metadata={content_metadata.content_key}' + ) logger.info('compare_catalog_queries_to_filters complete.')