module TouchFrequencyCapCheck

Overview

Count touches per contact inside a window of calendar days you set, and list the contacts above a cap you set. The window, the cap and "today" are all yours: the tool never reads the clock and knows no rule about what works.

Defined in:

touch_frequency_cap_check.cr

Constant Summary

MAX_LISTED = 20
REQUIRED = ["contact", "channel", "touched_on"] of ::String
USAGE = "usage: touch-frequency-cap-check touches.csv --today 2026-01-15 [--days 14] [--cap 3]\nCSV columns: contact, channel, touched_on (yyyy-mm-dd). --today is required; the window (--days, default 14) and the cap (--cap, default 3) are set by you. More: https://www.onegtmlab.dev/blog/the-abm-workflow-every-team-needs-in-2026"
VERSION = "1.0.0"

Class Method Summary

Class Method Detail

def self.analyse(touches : Array(Touch), today : Time, days : Int32, cap : Int32) : Report #

A touch is inside the window when 0 <= today - touched_on <= days - 1, that is the last days calendar days including today.


[View source]
def self.cli(args : Array(String), stdout : IO, stderr : IO) : Int32 #

Command line entry. Returns the exit code: 0 ok, 1 bad input or file, 2 usage.


[View source]
def self.fmt(t : Time) : String #

[View source]
def self.parse_csv(text : String) : Array(Array(String)) #

Small CSV reader: comma separated, double quoted fields may hold commas, line breaks and "" for a quote mark. Returns rows of raw cell strings.


[View source]
def self.parse_date(text : String) : Time | Nil #

yyyy-mm-dd only, a real calendar date. Returns UTC midnight of that day.


[View source]
def self.pct(v : Float64) : String #

[View source]
def self.read_touches(text : String, today : Time) : Array(Touch) #

Reads the rows. Contacts and channels are trimmed and compared without regard to case; the first spelling seen is the one shown.


[View source]
def self.render(r : Report) : String #

[View source]
def self.table(rows : Array(Array(String))) : String #

[View source]