Skip to content

Commit 12b6121

Browse files
committed
feat: add handle filtering to job query
1 parent cb8faeb commit 12b6121

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/algora/jobs/jobs.ex

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ defmodule Algora.Jobs do
2222
|> maybe_filter_by_status(opts)
2323
|> maybe_filter_by_user(opts)
2424
|> join(:inner, [j], u in User, on: u.id == j.user_id)
25+
|> maybe_filter_by_handle(opts[:handle])
2526
|> maybe_filter_by_tech_stack(opts[:tech_stack])
2627
|> join(:left, [j], i in JobInterview, on: i.job_posting_id == j.id)
2728
|> join(:left, [j], m in JobMatch, on: m.job_posting_id == j.id)
@@ -62,10 +63,17 @@ defmodule Algora.Jobs do
6263

6364
defp maybe_filter_by_user(query, _), do: query
6465

66+
defp maybe_filter_by_handle(query, nil), do: query
67+
68+
defp maybe_filter_by_handle(query, handle) do
69+
where(query, [j, u], u.handle == ^handle)
70+
end
71+
6572
defp maybe_filter_by_status(query, opts) do
6673
cond do
6774
opts[:status] == :all -> where(query, [j], j.status in [:active, :processing])
6875
opts[:user_id] -> where(query, [j], j.status in [:active, :processing])
76+
opts[:handle] -> where(query, [j, u], j.status in [:active, :processing])
6977
true -> where(query, [j], j.status in [:active])
7078
end
7179
end

0 commit comments

Comments
 (0)