Skip to content

Commit

Permalink
Fix search on Oban.Pro (#11)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
maltoe authored Nov 25, 2024
1 parent 9adc2a0 commit b562396
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions lib/obanalyze/oban_jobs.ex
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,21 @@ defmodule Obanalyze.ObanJobs do
defp filter(query, term) do
like = "%#{term}%"

case Oban.config() do
%{engine: Oban.Engines.Basic} ->
from oj in query,
where: ilike(oj.worker, ^like),
or_where: ilike(type(oj.args, :string), ^like)

_ ->
from oj in query,
where: like(oj.worker, ^like),
or_where: like(oj.args, ^like)
if postgres?() do
from oj in query,
where: ilike(oj.worker, ^like),
or_where: ilike(type(oj.args, :string), ^like)
else
from oj in query,
where: like(oj.worker, ^like),
or_where: like(type(oj.args, :string), ^like)
end
end

defp postgres? do
Oban.config().engine in [Oban.Engines.Basic, Oban.Pro.Engines.Smart]
end

defp jobs_count_query(job_state) do
Oban.Job
|> where([job], job.state == ^job_state)
Expand Down

0 comments on commit b562396

Please sign in to comment.