-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
2926: Fallback language in search function #3024
base: main
Are you sure you want to change the base?
Conversation
Does this issue already exist? Could you please link it here? Thanks :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested on firefox and android.
One thing I noticed: If the native app is still loading possible search results, the search bar is not shown. Even though this was already the case before, this change makes it more visible since there are two hooks loaded now at the same time. I also experienced it to disappear during typing alleinerziehend
as probably the German results where not yet available. We can also create a separate issue for this though.
const mainResults = useSearch(allPossibleResults, query) | ||
const fallbackResults = useSearch(allPossibleFallbackResults, query) | ||
|
||
const searchResults = mainResults?.length === 0 ? fallbackResults : mainResults |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 Hmmm.... I think minisearch often returns search results even if there are no direct matches in the content. What is the reason to not always returning both (main results first, fallback concatenated afterwards)?
const useMemoizeResults = ( | ||
categories?: CategoriesMapModel | null, | ||
events?: EventModel[] | null, | ||
pois?: PoiModel[] | null, | ||
) => useMemo(() => formatPossibleSearchResults(categories, events, pois), [categories, events, pois]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💭 Do we really have to memoize this? Doesn't really look calculation intense at all 🙈
}) | ||
const fallbackResults = useSearch(allPossibleFallbackResults, query) | ||
|
||
const results = mainResults?.length === 0 ? fallbackResults : mainResults |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 See native above
@@ -45,8 +46,16 @@ const SearchPage = ({ city, cityCode, languageCode, pathname }: CityRouteProps): | |||
language: languageCode, | |||
cmsApiBaseUrl, | |||
}) | |||
const mainResults = useSearch(allPossibleResults, query) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔧 I think something like contentResults
or contentLanguageResults
would be a little more speaking and explaining what is happening. Accordingly, fallbackLanguageResults
might be better.
const allPossibleResults = useMemo( | ||
() => [...(categories?.toArray().filter(category => !category.isRoot()) || []), ...(events || []), ...(pois || [])], | ||
[categories, events, pois], | ||
() => formatPossibleSearchResults(categories.data, events.data, pois.data), | ||
[categories.data, events.data, pois.data], | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔧 Same as for native
const { data: categories, ...categoriesReturn } = useLoadFromEndpoint(createCategoriesEndpoint, cmsApiBaseUrl, params) | ||
const { data: events, ...eventsReturn } = useLoadFromEndpoint(createEventsEndpoint, cmsApiBaseUrl, params) | ||
const { data: pois, ...poisReturn } = useLoadFromEndpoint(createPOIsEndpoint, cmsApiBaseUrl, params) | ||
const categories = useLoadFromEndpoint(createCategoriesEndpoint, cmsApiBaseUrl, params) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💭 In theory we could perhaps add a parameter include root
set to true as default or something to the categories endpoint so we don't have to filter it out after again?
Probably only really works well for web though, so not sure if its a good idea.
Short description
When your app is set to e.g. English and you look for a German term that you got a letter about like "Bürgergeld", you get zero results because we only search for English results. This PR adds a fallback language (the one that we translate from, i.e. German), so in this case, if there are no results in English, we then look in German.
The feedback screens have not been updated yet, that will be a separate ticket.
Proposed changes
Side effects
Testing
You can switch the app to English and search for "alleinerziehend".
Resolved issues
Partially fixes: #2926