# `PhoenixKitCatalogue.Catalogue.Counts`
[🔗](https://github.com/BeamLabEU/phoenix_kit_catalogue/blob/0.1.14/lib/phoenix_kit_catalogue/catalogue/counts.ex#L1)

Catalogue-level item and category counts. Includes both per-uuid
helpers and single-query batch versions to avoid N+1 lookups when
rendering catalogue lists with associated item / category counts.

Public surface is re-exported from `PhoenixKitCatalogue.Catalogue`.

# `category_count_for_catalogue`

```elixir
@spec category_count_for_catalogue(Ecto.UUID.t()) :: non_neg_integer()
```

Counts non-deleted categories for a catalogue.

# `category_counts_by_catalogue`

```elixir
@spec category_counts_by_catalogue() :: %{
  required(Ecto.UUID.t()) =&gt; non_neg_integer()
}
```

Returns a map of `catalogue_uuid => non_deleted_category_count`, in a
single query. Useful for displaying category counts alongside a
catalogue list (e.g. in the import wizard's catalogue picker) without
N+1 lookups.

# `deleted_category_count_for_catalogue`

```elixir
@spec deleted_category_count_for_catalogue(Ecto.UUID.t()) :: non_neg_integer()
```

Counts deleted categories for a catalogue.

# `deleted_count_for_catalogue`

```elixir
@spec deleted_count_for_catalogue(Ecto.UUID.t()) :: non_neg_integer()
```

Total count of deleted entities (items + categories) for a catalogue.

Used to determine whether to show the "Deleted" tab.

# `deleted_item_count_for_catalogue`

```elixir
@spec deleted_item_count_for_catalogue(Ecto.UUID.t()) :: non_neg_integer()
```

Counts deleted items in a catalogue, including items without a category.

# `item_count_for_catalogue`

```elixir
@spec item_count_for_catalogue(Ecto.UUID.t()) :: non_neg_integer()
```

Counts non-deleted items in a catalogue, including items without a category.

# `item_counts_by_catalogue`

```elixir
@spec item_counts_by_catalogue() :: %{required(Ecto.UUID.t()) =&gt; non_neg_integer()}
```

Returns a map of `%{catalogue_uuid => non_deleted_item_count}` for all catalogues.

Single-query batch version of `item_count_for_catalogue/1` — avoids N+1 when
displaying item counts alongside a catalogue list. Includes items both in
categories and directly attached to a catalogue (uncategorized).

---

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