Skip to content

Instantly share code, notes, and snippets.

@vhf
Created April 11, 2024 15:48
Show Gist options
  • Save vhf/1e7dac4c70da21bb959415cffd800a9e to your computer and use it in GitHub Desktop.
Save vhf/1e7dac4c70da21bb959415cffd800a9e to your computer and use it in GitHub Desktop.
oban job average duration
Oban.Job
|> where([j], j.completed_at > ago(5, "minute"))
|> select([j], fragment("EXTRACT(epoch FROM avg(? - ?))::int", j.completed_at, j.attempted_at))
|> Repo.one()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment