@@ -20,6 +20,7 @@ defmodule Algora.Jobs do
20
20
def list_jobs ( opts \\ [ ] ) do
21
21
query =
22
22
JobPosting
23
+ |> maybe_filter_by_ids ( opts [ :ids ] )
23
24
|> maybe_filter_by_status ( opts )
24
25
|> maybe_filter_by_user ( opts )
25
26
|> join ( :inner , [ j ] , u in User , on: u . id == j . user_id )
@@ -93,11 +94,18 @@ defmodule Algora.Jobs do
93
94
where ( query , [ j , u ] , u . handle == ^ handle )
94
95
end
95
96
97
+ defp maybe_filter_by_ids ( query , nil ) , do: query
98
+
99
+ defp maybe_filter_by_ids ( query , ids ) do
100
+ where ( query , [ j ] , j . id in ^ ids )
101
+ end
102
+
96
103
defp maybe_filter_by_status ( query , opts ) do
97
104
cond do
98
105
opts [ :status ] == :all -> where ( query , [ j ] , j . status in [ :active , :processing ] )
99
106
opts [ :user_id ] -> where ( query , [ j ] , j . status in [ :active , :processing ] )
100
107
opts [ :handle ] -> where ( query , [ j , u ] , j . status in [ :active , :processing ] )
108
+ opts [ :ids ] -> where ( query , [ j , u ] , j . status in [ :active , :processing ] )
101
109
true -> where ( query , [ j ] , j . status in [ :active ] )
102
110
end
103
111
end
0 commit comments