Commit Graph

2 Commits

Author SHA1 Message Date
53d65c2148 Add cascading fallback for deal titles instead of hardcoded "Unknown"
Replace the simple nil-title → "Unknown" logic in printDeal with a
fallbackDealTitle() function that tries multiple fields in priority
order before giving up:

  1. Title (cleaned) — the happy path, same as before
  2. Brand + Department — e.g. "Publix deal (Meat)"
  3. Brand alone — e.g. "Publix deal"
  4. Department alone — e.g. "Meat deal"
  5. Description truncated to 48 chars — last-resort meaningful text
  6. Item ID — e.g. "Deal 12345"
  7. "Untitled deal" — only when every field is empty

This makes the output more useful for the ~5-10% of weekly ad items
that ship with a nil Title from the Publix API, which previously all
showed as "Unknown" and were indistinguishable from each other.

Tests:
- TestPrintDeals_FallbackTitleFromBrandAndDepartment
- TestPrintDeals_FallbackTitleFromID

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 00:11:50 -05:00
73d55bc30e Add terminal display layer with lipgloss styling and JSON output
Rendering layer for deals, stores, and categories with two output
modes: styled terminal text using lipgloss (color-coded BOGO tags,
price highlights, dim metadata, word-wrapped descriptions) and
compact JSON for programmatic consumption.

JSON output types (DealJSON, StoreJSON) normalize raw API fields —
cleaning HTML entities, dereferencing nullable pointers, and
computing derived fields like isBogo. Terminal output includes
contextual headers with item counts and date ranges. Tests verify
both rendering modes including HTML entity handling and nil safety.
2026-02-22 21:41:53 -05:00