@@ -22,6 +22,7 @@ defmodule Algora.Jobs do
22
22
|> maybe_filter_by_status ( opts )
23
23
|> maybe_filter_by_user ( opts )
24
24
|> join ( :inner , [ j ] , u in User , on: u . id == j . user_id )
25
+ |> maybe_filter_by_handle ( opts [ :handle ] )
25
26
|> maybe_filter_by_tech_stack ( opts [ :tech_stack ] )
26
27
|> join ( :left , [ j ] , i in JobInterview , on: i . job_posting_id == j . id )
27
28
|> join ( :left , [ j ] , m in JobMatch , on: m . job_posting_id == j . id )
@@ -62,10 +63,17 @@ defmodule Algora.Jobs do
62
63
63
64
defp maybe_filter_by_user ( query , _ ) , do: query
64
65
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
+
65
72
defp maybe_filter_by_status ( query , opts ) do
66
73
cond do
67
74
opts [ :status ] == :all -> where ( query , [ j ] , j . status in [ :active , :processing ] )
68
75
opts [ :user_id ] -> where ( query , [ j ] , j . status in [ :active , :processing ] )
76
+ opts [ :handle ] -> where ( query , [ j , u ] , j . status in [ :active , :processing ] )
69
77
true -> where ( query , [ j ] , j . status in [ :active ] )
70
78
end
71
79
end
0 commit comments