Skip to content

Commit 20671a0

Browse files
committed
feat: improve match gen
1 parent 3bc6647 commit 20671a0

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

lib/algora/matches/matches.ex

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -68,28 +68,29 @@ defmodule Algora.Matches do
6868
system_tags: job.system_tags
6969
]
7070

71+
location_iso_lvl4 =
72+
if job.location_iso_lvl4 && job.countries && String.starts_with?(job.location_iso_lvl4, job.countries) do
73+
job.location_iso_lvl4
74+
end
75+
7176
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()
77+
if location_iso_lvl4 do
78+
opts
79+
|> Keyword.put(:location_iso_lvl4, location_iso_lvl4)
80+
|> Algora.Cloud.list_top_matches()
81+
else
82+
[]
83+
end
7884

7985
m2 =
8086
opts
81-
|> Keyword.put(
82-
:sort_by,
83-
[{"countries", job.countries}, {"regions", job.regions}]
84-
)
87+
|> Keyword.put(:location_iso_lvl4_not, location_iso_lvl4)
88+
|> Keyword.put(:countries, job.countries)
8589
|> Algora.Cloud.list_top_matches()
8690

8791
m3 =
8892
opts
89-
|> Keyword.put(
90-
:sort_by,
91-
[{"regions", job.regions}]
92-
)
93+
|> Keyword.put(:regions, job.regions)
9394
|> Algora.Cloud.list_top_matches()
9495

9596
matches = m1 ++ m2 ++ m3

0 commit comments

Comments
 (0)