Packages

Bildad is a job scheduling framework for Phoenix applications (works with LiveView). It is designed to be simple to use and easy to integrate into your existing Elixir applications.

Current section

Files

Jump to
bildad priv templates jobs_controller.ex.eex
Raw

priv/templates/jobs_controller.ex.eex

defmodule <%= application_name %>Web.Jobs.JobsController do
use <%= application_name %>Web, :controller
alias Bildad.Job.JobConfig
alias Bildad.Job.JobEngine
require Logger
def get_repo() do
<%= application_name %>.Repo
end
def run_job_engine(conn, _params) do
Logger.info("running job engine")
job_config = JobConfig.new(get_repo())
%{start: start_data, expire: expire_data} = JobEngine.run_job_engine(job_config)
engine_resp_data = %{
start: JobEngine.get_counts(start_data),
expire: JobEngine.get_counts(expire_data)
}
put_json(conn, engine_resp_data)
end
defp put_json(conn, resp_data) do
conn
|> put_resp_content_type("application/json")
|> send_resp(200, Jason.encode!(resp_data))
end
end