feat(server): 103 add configurable search formatting options #2423
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #103
Description
This PR introduces two new optional query parameters to the search API endpoint (
/api/search). These parameters allow external clients to disable specific formatting rules that are currently optimized for the web UI, enabling them to receive "rawer" data formats.Proposed Change(s)
The two new options are:
disable_cropping: Prevents the truncation (cropping) of long building names.disable_parsed_id_prefix: Prevents the addition of human-readable building prefixes (e.g., "MW", "MI") to theparsed_id, returning the raw Roomfinder format (archname@building_id) instead.Changes
routes/search.rs: Addeddisable_cropping: boolanddisable_parsed_id_prefix: booltoSearchQueryArgsas new path params and a new structFormattingConfigfor holding formatting config variables.search_executor/formatter.rs: UpdatedRoomVisitorto respect the new flags when generatingparsed_idand handling building name truncation.search_executor/mod.rs: Added new unit tests to confirm the correct behavior for both flags.external/meilisearch.rs: Integrated to use the newFormattingConfig.How to Test
Tests should pass (
cargo test). You can verify the functionality with a few test queries against a local instance:parsed_id)1010MW 1010 [Cropped Building Name…]1010&disable_cropping=trueMW 1010 [Full Building Name](no ellipsis)1010&disable_parsed_id_prefix=true1010@5510(raw Roomfinder ID)1010&disable_cropping=true&disable_parsed_id_prefix=true1010@5510(raw Roomfinder ID; cropping is ignored)