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.
Summary
Functions
Counts non-deleted categories for a catalogue.
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.
Counts deleted categories for a catalogue.
Total count of deleted entities (items + categories) for a catalogue.
Counts deleted items in a catalogue, including items without a category.
Counts non-deleted items in a catalogue, including items without a category.
Returns a map of %{catalogue_uuid => non_deleted_item_count} for all catalogues.
Functions
@spec category_count_for_catalogue(Ecto.UUID.t()) :: non_neg_integer()
Counts non-deleted categories for a catalogue.
@spec category_counts_by_catalogue() :: %{ required(Ecto.UUID.t()) => 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.
@spec deleted_category_count_for_catalogue(Ecto.UUID.t()) :: non_neg_integer()
Counts deleted categories for a catalogue.
@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.
@spec deleted_item_count_for_catalogue(Ecto.UUID.t()) :: non_neg_integer()
Counts deleted items in a catalogue, including items without a category.
@spec item_count_for_catalogue(Ecto.UUID.t()) :: non_neg_integer()
Counts non-deleted items in a catalogue, including items without a category.
@spec item_counts_by_catalogue() :: %{required(Ecto.UUID.t()) => 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).