Skip to content

Commit d21474b

Browse files
committed
refactor: update match criteria handling
1 parent cf73983 commit d21474b

File tree

2 files changed

+5
-22
lines changed

2 files changed

+5
-22
lines changed

lib/algora/settings/settings.ex

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -103,34 +103,17 @@ defmodule Algora.Settings do
103103
[
104104
tech_stack: job.tech_stack,
105105
limit: 50,
106-
users:
107-
case get_job_criteria(job.id) do
108-
criteria when map_size(criteria) > 0 ->
109-
apply_job_criteria(User, criteria)
110-
111-
_ ->
112-
from(u in User,
113-
where:
114-
not is_nil(u.hourly_rate_min) or
115-
fragment(
116-
"exists (select 1 from transactions t where t.user_id = ? and t.status = 'succeeded' and t.type = 'credit' and t.linked_transaction_id is not null)",
117-
u.id
118-
)
119-
)
106+
sort_by:
107+
case get_job_criteria(job) do
108+
criteria when map_size(criteria) > 0 -> criteria
109+
_ -> [{"solver", true}]
120110
end
121111
]
122112
|> Algora.Cloud.list_top_matches()
123113
|> load_matches_2()
124114
end
125115
end
126116

127-
def apply_job_criteria(query, criteria) do
128-
Enum.reduce(criteria, query, fn
129-
{"country", country}, query ->
130-
from([u] in query, where: u.country == ^country)
131-
end)
132-
end
133-
134117
def set_job_criteria(job_id, criteria) when is_binary(job_id) and is_map(criteria) do
135118
set("job_criteria:#{job_id}", %{"criteria" => criteria})
136119
end

lib/algora_web/live/org/job_live.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -842,7 +842,7 @@ defmodule AlgoraWeb.Org.JobLive do
842842
|> assign(:developers, developers)
843843
|> assign(:applicants, sort_by_contributions(socket.assigns.job, applicants, contributions_map))
844844
|> assign(:imports, sort_by_contributions(socket.assigns.job, imports, contributions_map))
845-
|> assign(:matches, sort_by_contributions(socket.assigns.job, matches, contributions_map))
845+
|> assign(:matches, matches)
846846
|> assign(:contributions_map, contributions_map)
847847
end
848848

0 commit comments

Comments
 (0)