PhoenixKitSync.Web.Receiver.Helpers (PhoenixKitSync v0.1.4)

Copy Markdown View Source

Pure formatting / parsing / counting helpers for the Receiver LiveView.

None of these touch the socket — they're display formatters (format_number/1, format_strategy/1, format_connection_error/1), input parsers (parse_id_list/1, parse_int/2), record accessors (get_record_id/1, get_table_info/2, get_schema_columns/1, filter_records_by_mode/2), and table-count comparators (fetch_local_counts/1, count_new_tables/2, count_different_tables/2, count_same_tables/2).

Extracted from Receiver in 2026-04 to shrink the LiveView module without changing any behavior.

Summary

Functions

count_different_tables(tables, local_counts)

@spec count_different_tables(list(), map()) :: non_neg_integer()

count_new_tables(tables, local_counts)

@spec count_new_tables(list(), map()) :: non_neg_integer()

count_same_tables(tables, local_counts)

@spec count_same_tables(list(), map()) :: non_neg_integer()

fetch_local_counts(tables)

@spec fetch_local_counts(list()) :: map()

filter_records_by_mode(records, arg2)

@spec filter_records_by_mode(list(), map()) :: list()

format_connection_error(reason)

@spec format_connection_error(any()) :: String.t()

format_number(num)

@spec format_number(any()) :: String.t()

format_strategy(atom)

@spec format_strategy(atom()) :: String.t()

get_record_id(record)

@spec get_record_id(any()) :: any()

get_schema_columns(schema)

@spec get_schema_columns(any()) :: list()

get_table_info(tables, table_name)

@spec get_table_info(list(), String.t()) :: map() | nil

parse_id_list(ids_string)

@spec parse_id_list(any()) :: [integer()]

parse_int(str, default)

@spec parse_int(any(), any()) :: any()