Mark the contacts that go over a per-domain cap in a CSV you supply.
Input columns: contact_id and email. The domain is the text after the last @,
trimmed and lower-cased. In input order the first cap contacts of each domain are
keep, later ones are over cap. Extra columns are ignored.
Every domain is counted the same, including a domain that belongs to a mailbox provider rather than a company: you decide what to do with those. The library reads no outside data.
Summary
Functions
Apply the cap. Returns a map with :cap, :contacts, :domains, :rows (each row plus
:decision, "keep" or "over cap", in input order), :over_domains (list of
{domain, ids}, count desc then domain) and :over_contacts.
The default cap (3). It is only a default: set it with --cap.
Parse CSV text into rows. Errors name the row (data rows are counted from 1, header excluded).
Percentage with one decimal, rounded half up, as text such as 30.8%.
Render the analysis as text.
The decisions as CSV text (contact_id,email,domain,decision), in input order.
Types
@type row() :: %{ row: pos_integer(), id: String.t(), email: String.t(), domain: String.t() }
Functions
@spec analyze([row()], pos_integer()) :: map()
Apply the cap. Returns a map with :cap, :contacts, :domains, :rows (each row plus
:decision, "keep" or "over cap", in input order), :over_domains (list of
{domain, ids}, count desc then domain) and :over_contacts.
The default cap (3). It is only a default: set it with --cap.
Parse CSV text into rows. Errors name the row (data rows are counted from 1, header excluded).
@spec pct(non_neg_integer(), non_neg_integer()) :: String.t()
Percentage with one decimal, rounded half up, as text such as 30.8%.
Render the analysis as text.
The decisions as CSV text (contact_id,email,domain,decision), in input order.