# `Lightning.WorkOrder`
[🔗](https://github.com/OpenFn/lightning/blob/main/lib/lightning/workorders/workorder.ex#L1)

Ecto model for WorkOrders.

# `t`

```elixir
@type t() :: %Lightning.WorkOrder{
  __meta__: Ecto.Schema.Metadata.t(),
  dataclip: Lightning.Invocation.Dataclip.t() | Ecto.Association.NotLoaded.t(),
  dataclip_id: term(),
  id: Ecto.UUID.t() | nil,
  inserted_at: term(),
  jobs: term(),
  last_activity: term(),
  runs: term(),
  snapshot: Lightning.Workflows.Snapshot.t() | Ecto.Association.NotLoaded.t(),
  snapshot_id: term(),
  state: atom(),
  trigger: Lightning.Workflows.Trigger.t() | Ecto.Association.NotLoaded.t(),
  trigger_id: term(),
  updated_at: term(),
  workflow: Lightning.Workflows.Workflow.t() | Ecto.Association.NotLoaded.t(),
  workflow_id: term()
}
```

# `active_states`

Returns the list of active (in-progress) work order states.

# `failure_states`

Returns the list of failure states for a work order.

These are all final states except `:success` and `:cancelled` — someone
stopped a cancelled work order on purpose, so it is not a failure.

# `final_states`

Returns the list of final states for a work order.

Every state a work order can settle in: `Run.final_states/0` plus
`:rejected`, which is what a work order whose run was never created settles
in.

# `outcome`

Buckets a work order state into `:success`, `:cancelled`, `:pending` or
`:failed`.

# `states`

Returns all possible states for a work order.

# `validate`

---

*Consult [api-reference.md](api-reference.md) for complete listing*
