Skip to content

Commit 3531040

Browse files
committed
feat: improve sorting logic
1 parent 20671a0 commit 3531040

File tree

2 files changed

+43
-3
lines changed

2 files changed

+43
-3
lines changed

lib/algora/matches/matches.ex

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ defmodule Algora.Matches do
6060
ids_not = Enum.map(existing_matches, & &1.user_id) ++ Enum.map(discarded_matches, & &1.user_id)
6161

6262
opts = [
63-
limit: 6,
6463
ids_not: ids_not,
6564
tech_stack: job.tech_stack,
6665
has_min_compensation: true,
@@ -69,13 +68,15 @@ defmodule Algora.Matches do
6968
]
7069

7170
location_iso_lvl4 =
72-
if job.location_iso_lvl4 && job.countries && String.starts_with?(job.location_iso_lvl4, job.countries) do
71+
if job.location_iso_lvl4 && job.countries &&
72+
Enum.any?(job.countries, &String.starts_with?(job.location_iso_lvl4, &1)) do
7373
job.location_iso_lvl4
7474
end
7575

7676
m1 =
7777
if location_iso_lvl4 do
7878
opts
79+
|> Keyword.put(:limit, 6)
7980
|> Keyword.put(:location_iso_lvl4, location_iso_lvl4)
8081
|> Algora.Cloud.list_top_matches()
8182
else
@@ -84,13 +85,15 @@ defmodule Algora.Matches do
8485

8586
m2 =
8687
opts
88+
|> Keyword.put(:limit, max(6 - length(m1), 3))
8789
|> Keyword.put(:location_iso_lvl4_not, location_iso_lvl4)
8890
|> Keyword.put(:countries, job.countries)
8991
|> Algora.Cloud.list_top_matches()
9092

9193
m3 =
9294
opts
93-
|> Keyword.put(:regions, job.regions)
95+
|> Keyword.put(:limit, 3)
96+
|> Keyword.put(:sort_by, [{"regions", job.regions}])
9497
|> Algora.Cloud.list_top_matches()
9598

9699
matches = m1 ++ m2 ++ m3

lib/algora/psp/connect_countries.ex

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,43 @@ defmodule Algora.PSP.ConnectCountries do
291291
"TZ",
292292
"ZA"
293293
],
294+
"AMERICAS" => [
295+
"US",
296+
"CA",
297+
"BR",
298+
"MX",
299+
"CO",
300+
"AR",
301+
"PE",
302+
"VE",
303+
"CL",
304+
"GT",
305+
"EC",
306+
"BO",
307+
"HT",
308+
"DO",
309+
"HN",
310+
"CU",
311+
"PY",
312+
"NI",
313+
"SV",
314+
"CR",
315+
"PA",
316+
"UY",
317+
"JM",
318+
"TT",
319+
"GY",
320+
"SR",
321+
"BZ",
322+
"BS",
323+
"BB",
324+
"LC",
325+
"GD",
326+
"VC",
327+
"AG",
328+
"DM",
329+
"KN"
330+
],
294331
"NA" => [
295332
"US",
296333
"CA"

0 commit comments

Comments
 (0)