action-requests-demo.jamey..../test/support/factory.ex
Jamey Greenwood de1b1bd484 Initial commit: Phoenix LiveView demo for interactive data tables with filtering, sorting, pagination, URL state, and progressive enhancement
Implements a fully-featured action requests table in a single LiveView module using Flop, Ecto, and SQLite. Includes:

- Fuzzy search, status/assignment filters, column sorting, 25-per-page pagination
- Real-time updates, bookmarkable URLs via `handle_params/3`
- JS-disabled fallback with GET forms (no duplicate logic)
- 1,000,000 seeded records, Tailwind + DaisyUI styling, light/dark themes
- Comprehensive README with comparisons to Django+React/Rails+React stacks
- 31 tests covering all scenarios

Tech: Phoenix 1.8+, LiveView, Flop, Ecto, SQLite, Elixir 1.15+
2025-11-16 10:24:06 +00:00

18 lines
548 B
Elixir

defmodule ActionRequestsDemo.Factory do
alias ActionRequestsDemo.Repo
alias ActionRequestsDemo.ActionRequests.ActionRequest
def insert_action_request(attrs \\ %{}) do
default_attrs = %{
patient_name: "Patient #{System.unique_integer([:positive])}",
status: Enum.random(["resolved", "unresolved"]),
assigned_user_id: Enum.random([nil, 1, 2]),
delivery_scheduled_at: ~N[2025-11-16 10:00:00]
}
%ActionRequest{}
|> ActionRequest.changeset(Map.merge(default_attrs, attrs))
|> Repo.insert!()
end
end