feat(search): default_location календарей в ответе всегда (для вида карты)
CI / test (push) Successful in 7m56s
CI / deploy-ift (push) Successful in 3m31s
CI / e2e-ift (push) Successful in 1m18s
CI / deploy-stage (push) Successful in 2m15s
CI / e2e-stage (push) Successful in 1m48s

format_calendar больше не требует geo_origin: default_location (address/
lat/lon либо null) включается в ответ GET /v1/search всегда, если точка
задана, — вид карты на странице поиска строится и без lat/lon в запросе.
distance_km по-прежнему возвращается только при гео-запросе.

Refs EventHub/EventHubBack#77
This commit is contained in:
2026-08-19 22:01:07 +03:00
parent 73d43e5fdc
commit cc08b3b18a
2 changed files with 22 additions and 6 deletions
+17
View File
@@ -29,6 +29,7 @@ logic_search_test_() ->
{"Combined search", fun test_combined_search/0},
{"Search calendars", fun test_search_calendars/0},
{"Search calendars include image_url", fun test_search_calendars_image_url/0},
{"Calendars expose default_location without geo params", fun test_calendars_default_location_always/0},
{"Search all", fun test_search_all/0},
{"Pagination", fun test_pagination/0},
{"Sorting", fun test_sorting/0},
@@ -243,6 +244,22 @@ test_search_calendars_image_url() ->
[Hit | _] = [C || C <- Cals, maps:get(id, C) =:= CalendarId],
?assertEqual(<<"https://cdn.example/cal.jpg">>, maps:get(image_url, Hit)).
%% Вид карты на странице поиска строит маркеры без lat/lon в запросе —
%% координаты календаря должны приходить всегда; distance_km — нет.
test_calendars_default_location_always() ->
OwnerId = create_test_user(user),
WithLocId = create_test_calendar(OwnerId, commercial, []),
BareId = create_test_calendar(OwnerId, commercial, []),
set_default_location(WithLocId, <<"Moscow">>, 55.7558, 37.6173),
{_, Hits} = calendars_from(logic_search:search(<<"calendar">>, <<"Calendar">>, OwnerId, #{})),
[WithLoc] = [C || C <- Hits, maps:get(id, C) =:= WithLocId],
[Bare] = [C || C <- Hits, maps:get(id, C) =:= BareId],
?assertMatch(#{<<"lat">> := 55.7558, <<"lon">> := 37.6173},
maps:get(default_location, WithLoc)),
?assertEqual(null, maps:get(default_location, Bare)),
?assert(not maps:is_key(distance_km, WithLoc)).
test_search_all() ->
OwnerId = create_test_user(user),
CalendarId = create_test_calendar(OwnerId, commercial, []),