Packages

A Fair Source multi-agent runtime with deterministic agent scoring and replayable run history.

Retired package: Deprecated - superseded — operator console moved to the Syntropy app

Current section

Files

Jump to
syntropy lib syntropy_web controllers api history_controller.ex
Raw

lib/syntropy_web/controllers/api/history_controller.ex

defmodule SyntropyWeb.Api.HistoryController do
use SyntropyWeb, :controller
alias SyntropyWeb.Api.{ControllerHelpers, HistoryJSON}
@spec index(Plug.Conn.t(), map()) :: Plug.Conn.t()
def index(conn, params) do
limit = ControllerHelpers.limit(params)
json(conn, %{data: Enum.map(Syntropy.recent_snapshots(limit), &HistoryJSON.snapshot/1)})
end
@spec show(Plug.Conn.t(), map()) :: Plug.Conn.t()
def show(conn, %{"id" => snapshot_id}) do
case Syntropy.snapshot(snapshot_id) do
nil -> ControllerHelpers.not_found(conn, "Snapshot", snapshot_id)
snapshot -> json(conn, %{data: HistoryJSON.snapshot(snapshot)})
end
end
end