Skip to content

Commit

Permalink
Merge pull request #835 from openedx/eahmadjaved/ENT-8859
Browse files Browse the repository at this point in the history
feat: add default availability filter in catalog algolia query
  • Loading branch information
jajjibhai008 authored May 22, 2024
2 parents 0133c8f + 729f23c commit 8b731d9
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion enterprise_catalog/apps/ai_curation/utils/algolia_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def extract_course_data(hit: dict):
'program_titles': hit.get('program_titles', []),
'skills': hit.get('skill_names', []),
'subjects': hit.get('subjects', []),
'availability': hit.get('availability', [])
}


Expand All @@ -66,12 +67,23 @@ def fetch_catalog_metadata_from_algolia(enterprise_catalog_query_title: str):
"""
algolia_client = get_initialized_algolia_client()
search_options = {
'facetFilters': [f'enterprise_catalog_query_titles:{enterprise_catalog_query_title}', ],
'facetFilters': [
[
'availability:Available Now',
'availability:Starting Soon',
'availability:Upcoming'
],
[
f'enterprise_catalog_query_titles:{enterprise_catalog_query_title}'
]
],
'filters': 'learning_type:course OR learning_type:program OR learning_type:"Executive Education"',
'attributesToRetrieve': [
'key',
'aggregation_key',
'content_type',
'course_type',
'availability',
'title',
'short_description',
'full_description',
Expand All @@ -80,6 +92,7 @@ def fetch_catalog_metadata_from_algolia(enterprise_catalog_query_title: str):
'skill_names',
'subjects',
],
'facetingAfterDistinct': True,
'hitsPerPage': 100,
'page': 0,
}
Expand Down

0 comments on commit 8b731d9

Please sign in to comment.