feat(geo): Photon proxy, address-only location, nearby search. Refs EventHub/EventHubBack#77
CI / test (push) Successful in 7m38s
CI / deploy-ift (push) Successful in 3m27s
CI / e2e-ift (push) Successful in 1m16s
CI / deploy-stage (push) Successful in 2m18s
CI / e2e-stage (push) Successful in 4m11s

This commit is contained in:
2026-08-17 23:23:10 +03:00
parent 501334e241
commit 6b70e1336d
14 changed files with 919 additions and 90 deletions
+56
View File
@@ -23,6 +23,9 @@ logic_search_test_() ->
{"Search events by tags", fun test_search_events_by_tags/0},
{"Search events by date range", fun test_search_events_by_date/0},
{"Search events by location", fun test_search_events_by_location/0},
{"Search calendars by location", fun test_search_calendars_by_location/0},
{"Geo without radius keeps distant hits", fun test_geo_no_radius/0},
{"Geo sort by distance", fun test_geo_sort_distance/0},
{"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},
@@ -152,6 +155,59 @@ test_search_events_by_location() ->
#{lat => 59.9343, lon => 30.3351, radius => 10})),
?assertEqual(1, Total2).
test_search_calendars_by_location() ->
OwnerId = create_test_user(user),
NearId = create_test_calendar(OwnerId, commercial, []),
FarId = create_test_calendar(OwnerId, commercial, []),
set_default_location(NearId, <<"Moscow">>, 55.7558, 37.6173),
set_default_location(FarId, <<"SPb">>, 59.9343, 30.3351),
{Total, Hits} = calendars_from(logic_search:search(<<"calendar">>, undefined, OwnerId,
#{lat => 55.7558, lon => 37.6173, radius => 10})),
?assertEqual(1, Total),
[Hit] = Hits,
?assertEqual(NearId, maps:get(id, Hit)),
?assert(maps:is_key(distance_km, Hit)).
test_geo_no_radius() ->
OwnerId = create_test_user(user),
CalendarId = create_test_calendar(OwnerId, commercial, []),
StartTime = eh_test_support:future_start(),
MoscowLoc = #location{address = <<"Moscow">>, lat = 55.7558, lon = 37.6173},
SpbLoc = #location{address = <<"SPb">>, lat = 59.9343, lon = 30.3351},
create_test_event(CalendarId, <<"Moscow Event">>, <<"">>, StartTime, [], MoscowLoc),
create_test_event(CalendarId, <<"SPb Event">>, <<"">>, StartTime, [], SpbLoc),
{Total, _} = events_from(logic_search:search(<<"event">>, undefined, OwnerId,
#{lat => 55.7558, lon => 37.6173})),
?assertEqual(2, Total).
test_geo_sort_distance() ->
OwnerId = create_test_user(user),
CalendarId = create_test_calendar(OwnerId, commercial, []),
StartTime = eh_test_support:future_start(),
MoscowLoc = #location{address = <<"Moscow">>, lat = 55.7558, lon = 37.6173},
SpbLoc = #location{address = <<"SPb">>, lat = 59.9343, lon = 30.3351},
create_test_event(CalendarId, <<"Moscow Event">>, <<"">>, StartTime, [], MoscowLoc),
create_test_event(CalendarId, <<"SPb Event">>, <<"">>, StartTime, [], SpbLoc),
{_, [First | _]} = events_from(logic_search:search(<<"event">>, undefined, OwnerId,
#{lat => 55.7558, lon => 37.6173})),
?assertMatch(#{title := <<"Moscow Event">>}, First),
?assert(maps:is_key(distance_km, First)).
set_default_location(CalendarId, Addr, Lat, Lon) ->
{ok, Cal} = core_calendar:get_by_id(CalendarId),
Settings0 = case Cal#calendar.settings of
M when is_map(M) -> M;
_ -> #{}
end,
Settings = Settings0#{
<<"default_location">> => #{
<<"address">> => Addr,
<<"lat">> => Lat,
<<"lon">> => Lon
}
},
core_calendar:update(CalendarId, [{settings, Settings}]).
test_combined_search() ->
OwnerId = create_test_user(user),
CalendarId = create_test_calendar(OwnerId, commercial, []),