Skip to content

Commit b562396

Browse files
authored
Fix search on Oban.Pro (#11)
The adapter detection we implemented in 30e2d6c doesn't work for Oban.Pro when one uses the `Smart` engine. Changed to a) assume Postgres for both `Basic` and `Smart`, b) let the fallback also explicitly type cast the jsonb column, which I believe shouldn't matter on sqlite.
1 parent 9adc2a0 commit b562396

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

lib/obanalyze/oban_jobs.ex

+12-10
Original file line numberDiff line numberDiff line change
@@ -57,19 +57,21 @@ defmodule Obanalyze.ObanJobs do
5757
defp filter(query, term) do
5858
like = "%#{term}%"
5959

60-
case Oban.config() do
61-
%{engine: Oban.Engines.Basic} ->
62-
from oj in query,
63-
where: ilike(oj.worker, ^like),
64-
or_where: ilike(type(oj.args, :string), ^like)
65-
66-
_ ->
67-
from oj in query,
68-
where: like(oj.worker, ^like),
69-
or_where: like(oj.args, ^like)
60+
if postgres?() do
61+
from oj in query,
62+
where: ilike(oj.worker, ^like),
63+
or_where: ilike(type(oj.args, :string), ^like)
64+
else
65+
from oj in query,
66+
where: like(oj.worker, ^like),
67+
or_where: like(type(oj.args, :string), ^like)
7068
end
7169
end
7270

71+
defp postgres? do
72+
Oban.config().engine in [Oban.Engines.Basic, Oban.Pro.Engines.Smart]
73+
end
74+
7375
defp jobs_count_query(job_state) do
7476
Oban.Job
7577
|> where([job], job.state == ^job_state)

0 commit comments

Comments
 (0)