LightningWeb.Live.AiAssistant.PaginationMeta (Lightning v2.14.5-pre1)

View Source

Pagination metadata for AI Assistant sessions.

Handles offset-based pagination and infinite scroll patterns.

Summary

Functions

Calculates database offset for current page.

Checks if on first page.

Creates metadata for a specific page.

Checks if on last page.

Creates pagination metadata from current state.

Returns page numbers for navigation display.

Generates human-readable pagination summary.

Calculates total number of pages.

Types

t()

@type t() :: %LightningWeb.Live.AiAssistant.PaginationMeta{
  current_page: pos_integer(),
  has_next_page: boolean(),
  has_prev_page: boolean(),
  page_size: pos_integer(),
  total_count: non_neg_integer()
}

Functions

current_offset(pagination_meta)

@spec current_offset(t()) :: non_neg_integer()

Calculates database offset for current page.

first_page?(pagination_meta)

@spec first_page?(t()) :: boolean()

Checks if on first page.

for_page(pagination_meta, target_page)

@spec for_page(t(), pos_integer()) :: t()

Creates metadata for a specific page.

last_page?(pagination_meta)

@spec last_page?(t()) :: boolean()

Checks if on last page.

new(current_sessions_count, page_size, total_count)

@spec new(non_neg_integer(), pos_integer(), non_neg_integer()) :: t()

Creates pagination metadata from current state.

Examples

iex> new(25, 20, 100)
%PaginationMeta{current_page: 2, page_size: 20, total_count: 100, has_next_page: true, has_prev_page: true}

page_range(meta, max_pages \\ 5)

@spec page_range(t(), pos_integer()) :: [pos_integer()]

Returns page numbers for navigation display.

Centers around current page with max visible pages.

summary(pagination_meta)

@spec summary(t()) :: String.t()

Generates human-readable pagination summary.

Examples

iex> summary(%PaginationMeta{current_page: 2, page_size: 20, total_count: 45})
"Showing 21-40 of 45"

total_pages(pagination_meta)

@spec total_pages(t()) :: pos_integer()

Calculates total number of pages.