Skip to content

Commit 3bc6647

Browse files
committed
feat: refine sorting criteria
1 parent 5e7cb26 commit 3bc6647

File tree

1 file changed

+32
-5
lines changed

1 file changed

+32
-5
lines changed

lib/algora/matches/matches.ex

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,43 @@ defmodule Algora.Matches do
5959

6060
ids_not = Enum.map(existing_matches, & &1.user_id) ++ Enum.map(discarded_matches, & &1.user_id)
6161

62-
[
63-
limit: 6 - length(existing_matches),
62+
opts = [
63+
limit: 6,
6464
ids_not: ids_not,
6565
tech_stack: job.tech_stack,
6666
has_min_compensation: true,
6767
not_discarded: true,
68-
system_tags: job.system_tags,
69-
sort_by: [{"countries", job.countries}, {"regions", job.regions}]
68+
system_tags: job.system_tags
7069
]
71-
|> Algora.Cloud.list_top_matches()
70+
71+
m1 =
72+
opts
73+
|> Keyword.put(
74+
:sort_by,
75+
[{"location_iso_lvl4s", [job.location_iso_lvl4]}, {"countries", job.countries}, {"regions", job.regions}]
76+
)
77+
|> Algora.Cloud.list_top_matches()
78+
79+
m2 =
80+
opts
81+
|> Keyword.put(
82+
:sort_by,
83+
[{"countries", job.countries}, {"regions", job.regions}]
84+
)
85+
|> Algora.Cloud.list_top_matches()
86+
87+
m3 =
88+
opts
89+
|> Keyword.put(
90+
:sort_by,
91+
[{"regions", job.regions}]
92+
)
93+
|> Algora.Cloud.list_top_matches()
94+
95+
matches = m1 ++ m2 ++ m3
96+
97+
matches
98+
|> Enum.uniq_by(& &1.user_id)
7299
|> Algora.Settings.load_matches_2()
73100
end
74101

0 commit comments

Comments
 (0)