Skip to content

Commit

Permalink
WIP - build query parameters for Algolia
Browse files Browse the repository at this point in the history
  • Loading branch information
tconte-pass committed Jan 9, 2025
1 parent 2f49516 commit 992cd6b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/libs/algolia/enums/facetsEnums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ export enum FACETS_FILTERS_ENUM {
OFFER_MOVIE_GENRES = 'offer.movieGenres',
OFFER_MUSIC_TYPE = 'offer.musicType',
OFFER_NATIVE_CATEGORY = 'offer.nativeCategoryId',
OFFER_SEARCH_GROUP_NAME = 'offer.searchGroupNamev2',
OFFER_SEARCH_GROUP_NAME = 'offer.searchGroups',
OFFER_SEARCH_GROUP_NAME_V2 = 'offer.searchGroupNamev2',
OFFER_SHOW_TYPE = 'offer.showType',
OFFER_SUB_CATEGORY = 'offer.subcategoryId',
OFFER_TAGS = 'offer.tags',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ export const buildFacetFilters = ({
if (isUserUnderage) facetFilters.push(...underageFilter)

if (offerCategories.length > 0) {
const categoriesPredicate = buildOfferCategoriesPredicate(offerCategories)
const categoriesPredicate = buildOfferCategoriesPredicate(
offerCategories
.map((categoryKey) => getCategory(categoryKey))
.filter((category) => !!category)
)
facetFilters.push(categoriesPredicate)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import { FiltersArray, SearchQueryParameters } from 'libs/algolia/types'
import { eventMonitoring } from 'libs/monitoring'
import { GtlLevel } from 'shared/gtl/types'

export const buildOfferCategoriesPredicate = (searchGroups: SearchGroupNameEnumv2[]): string[] =>
searchGroups.map((searchGroup) => `${FACETS_FILTERS_ENUM.OFFER_SEARCH_GROUP_NAME}:${searchGroup}`)
export const buildOfferCategoriesPredicate = (categories: BaseCategory[]): string[] =>
categories
.filter((category) => !!category.searchFilter && !!category.searchValue)
.map((category) => `${category.searchFilter}:${category.searchValue}`)

export const buildOfferSubcategoriesPredicate = (subcategoryIds: SubcategoryIdEnumv2[]): string[] =>
subcategoryIds.map(
Expand Down

0 comments on commit 992cd6b

Please sign in to comment.