towerops/lib/towerops_web/graphql/resolvers/activity.ex
Graham McIntire 146f5745cf
fix: resolve compilation errors, test failures, and credo issues
- Escape HEEx template braces in GraphQL/API docs with raw(~S[...])
- Fix test assertions for updated marketing copy and UI text
- Extract helper functions in GraphQL resolvers to reduce nesting depth
- Create shared ErrorHelpers module for API controllers
- Fix ETS race condition in brute force whitelist cache for async tests
- Fix property test generators to use ASCII instead of printable unicode
- Add alert_severity helper to site_live/show
- Update accounts fixtures for explicit user confirmation
2026-02-14 12:23:10 -06:00

29 lines
742 B
Elixir

defmodule ToweropsWeb.GraphQL.Resolvers.Activity do
@moduledoc "GraphQL resolvers for activity feed."
alias Towerops.ActivityFeed
def list(_parent, args, %{context: %{organization_id: org_id}}) do
opts = maybe_add_type([limit: Map.get(args, :limit, 50)], args[:type])
items = ActivityFeed.list_org_activity(org_id, opts)
{:ok, items}
end
def list(_parent, _args, _resolution), do: {:error, "Authentication required"}
defp maybe_add_type(opts, nil), do: opts
defp maybe_add_type(opts, type) do
case safe_to_atom(type) do
nil -> opts
atom -> Keyword.put(opts, :types, [atom])
end
end
defp safe_to_atom(str) do
String.to_existing_atom(str)
rescue
ArgumentError -> nil
end
end