# `PgFlowDashboard.Queries.Runs`
[🔗](https://github.com/agoodway/pgflow/blob/v0.1.0/lib/pgflow_dashboard/queries/runs.ex#L1)

Database queries for run-related data.

# `count_runs`

```elixir
@spec count_runs(
  module(),
  keyword()
) :: integer()
```

Counts runs matching the given filters.

## Options

  * `:flow_slug` - Filter by flow slug
  * `:status` - Filter by status (started, completed, failed)
  * `:time_range` - Filter by time range (:last_hour, :last_24h, :last_7d, :last_30d)
  * `:flow_type` - Filter by type ("flow" or "job")

# `get_adjacent_run`

```elixir
@spec get_adjacent_run(module(), String.t(), :next | :prev) ::
  {:ok, String.t()} | {:error, :not_found}
```

Gets the adjacent run (next or previous by started_at).

Direction can be :next or :prev.
Returns {:ok, run_id} or {:error, :not_found}.

# `get_run`

```elixir
@spec get_run(module(), String.t()) :: {:ok, map()} | {:error, :not_found | term()}
```

Gets a single run with full details.

# `list_runs`

```elixir
@spec list_runs(
  module(),
  keyword()
) :: [map()]
```

Lists runs with progress information.

## Options

  * `:flow_slug` - Filter by flow slug
  * `:status` - Filter by status (started, completed, failed)
  * `:time_range` - Filter by time range (:last_hour, :last_24h, :last_7d, :last_30d)
  * `:limit` - Maximum number of runs to return (default: 50)
  * `:cursor` - Cursor for pagination (run_id to start after)
  * `:flow_type` - Filter by type ("flow" or "job")

# `list_step_states`

```elixir
@spec list_step_states(module(), String.t()) :: [map()]
```

Lists step states for a run.

# `list_step_tasks`

```elixir
@spec list_step_tasks(module(), String.t(), String.t()) :: [map()]
```

Lists tasks for a specific step in a run.

---

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