From 5ca18eb24609784bcd6776df65fec20b3b5b5502 Mon Sep 17 00:00:00 2001 From: Alexander Timmermann <alex@timmermann.me> Date: Mon, 22 Jan 2024 10:12:01 +0100 Subject: [PATCH] fix: prefer results from Germany before other countries When searching for e.g. "Berlin" we currently find results from the US first. As we also limit to only 3 results, the correct Berlin only shows up when adding the country explicitly. As our userbase is almost exclusively located in Germany, a preference for German places makes sense. refs HOLI-7063 --- app/geoapify.ts | 1 + app/geoapify_api_types.ts | 1 + app/geoapify_test.ts | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/geoapify.ts b/app/geoapify.ts index 4a72a20..62f6432 100644 --- a/app/geoapify.ts +++ b/app/geoapify.ts @@ -25,6 +25,7 @@ const buildPlacesAutocompleteUrl = ( url.searchParams.append("limit", limit.toString()); url.searchParams.append("format", GeoapifyFilters.FORMAT); url.searchParams.append("lang", language); + url.searchParams.append("bias", GeoapifyFilters.BIAS); url.searchParams.append("apiKey", geoapifyApiKey); if (level) { diff --git a/app/geoapify_api_types.ts b/app/geoapify_api_types.ts index 96018c5..6c958d8 100644 --- a/app/geoapify_api_types.ts +++ b/app/geoapify_api_types.ts @@ -30,4 +30,5 @@ export type GeoapifyPlaceDetailsResult = { export enum GeoapifyFilters { LIMIT = 3, FORMAT = "json", + BIAS = "countrycode:de", } diff --git a/app/geoapify_test.ts b/app/geoapify_test.ts index 3abbf1e..4cf7f66 100644 --- a/app/geoapify_test.ts +++ b/app/geoapify_test.ts @@ -100,7 +100,7 @@ describe("places", () => { ); const expectedUrl = new URL( - `https://api.geoapify.com/v1/geocode/autocomplete?text=Munich&limit=3&format=json&lang=en&apiKey=${placesApiKey}`, + `https://api.geoapify.com/v1/geocode/autocomplete?text=Munich&limit=3&format=json&lang=en&bias=countrycode%3Ade&apiKey=${placesApiKey}`, ); assertSpyCall(fetchStub, 0, { args: [expectedUrl] }); }); -- GitLab