# `GanttEx.ResourceLoad`
[🔗](https://github.com/rocket4ce/gantt_ex/blob/v0.1.0/lib/gantt_ex/resource_load.ex#L1)

Computes how loaded each resource is, column by column of the timeline.

For every column, the load of a resource is the sum, over the tasks
assigned to it, of the assigned units per day multiplied by the days the
task overlaps the column. The capacity is the resource capacity multiplied
by the days of the column. With working time both only count working time,
using the task calendars and the global calendar.

An assignment without a value uses the whole capacity of the resource.

    iex> store = GanttEx.Store.new!([
    ...>   %{id: 1, start_date: ~D[2025-01-06], duration: 2, resources: [%{resource_id: "ana", value: 6}]},
    ...>   %{id: 2, start_date: ~D[2025-01-07], duration: 2, resources: ["ana"]}
    ...> ])
    iex> timeline = GanttEx.Timeline.new(scales: [[unit: :day]], start_date: ~N[2025-01-06 00:00:00], end_date: ~N[2025-01-10 00:00:00], column_width: 40)
    iex> [row] = GanttEx.ResourceLoad.compute(store, [%{id: "ana", text: "Ana"}], timeline)
    iex> Enum.map(row.cells, &{&1.start.day, &1.load, &1.overload})
    [{6, 6.0, false}, {7, 14.0, true}, {8, 8.0, false}]
    iex> row.overloaded
    true

# `cell`

```elixir
@type cell() :: %{
  start: NaiveDateTime.t(),
  end: NaiveDateTime.t(),
  x: number(),
  width: number(),
  load: float(),
  capacity: float(),
  overload: boolean(),
  tasks: [GanttEx.Task.id()]
}
```

The load of a resource in one column (only columns with load are returned).

# `row`

```elixir
@type row() :: %{
  resource: GanttEx.Resource.t(),
  cells: [cell()],
  overloaded: boolean()
}
```

# `compute`

```elixir
@spec compute(GanttEx.Store.t(), [term()], GanttEx.Timeline.t()) :: [row()]
```

Returns one row per resource, in the given order.

---

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