@@ -20,6 +20,7 @@ defmodule Algora.Jobs do
2020 def list_jobs ( opts \\ [ ] ) do
2121 query =
2222 JobPosting
23+ |> maybe_filter_by_ids ( opts [ :ids ] )
2324 |> maybe_filter_by_status ( opts )
2425 |> maybe_filter_by_user ( opts )
2526 |> join ( :inner , [ j ] , u in User , on: u . id == j . user_id )
@@ -93,11 +94,18 @@ defmodule Algora.Jobs do
9394 where ( query , [ j , u ] , u . handle == ^ handle )
9495 end
9596
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+
96103 defp maybe_filter_by_status ( query , opts ) do
97104 cond do
98105 opts [ :status ] == :all -> where ( query , [ j ] , j . status in [ :active , :processing ] )
99106 opts [ :user_id ] -> where ( query , [ j ] , j . status in [ :active , :processing ] )
100107 opts [ :handle ] -> where ( query , [ j , u ] , j . status in [ :active , :processing ] )
108+ opts [ :ids ] -> where ( query , [ j , u ] , j . status in [ :active , :processing ] )
101109 true -> where ( query , [ j ] , j . status in [ :active ] )
102110 end
103111 end
0 commit comments