iachat/enterprise/app/services
Rodribm10 f6488ce2de feat(retention): foundation for customer retention metrics
Lays the data + job foundation for tracking customer interactions,
recurrence, and Pix conversion on Contact. Design decisions negotiated
with Rodrigo (see docs to come):

Rules:
- Gap of 30h from last message defines separate interactions
- Qualified interaction = >=2 customer msgs + >=2 attendant msgs,
  both with textual content (>= 2 letters)
- One-shot consultation = >=1+1 but below the qualified threshold
  (tracked as secondary KPI)
- Excludes contacts labeled `equipe_interna`
- is_recurring = interactions_count >= 2
- pix_generated_count counts all PixCharges; reservations_paid_count
  only counts those with status = paid

Surface area:
- Migration adds denormalized stats to contacts + indexes for fast filtering
- Captain::ContactStats::InteractionCalculatorService computes the stats
  for a single contact (pure, no persistence)
- Captain::Retention::RecalculateContactStatsJob persists them for one
  contact (idempotent)
- Captain::Retention::RecalculateAllContactStatsJob runs daily at 3am BRT,
  enqueues per-contact jobs for everyone active in the last 120 days
- Event-driven refresh: CaptainListener#conversation_resolved enqueues
  recalc; Captain::PixCharge after_create/after_update enqueues recalc
  on status change

No UI yet — that's the next layer.
2026-04-22 09:50:23 -03:00
..
captain feat(retention): foundation for customer retention metrics 2026-04-22 09:50:23 -03:00
cloudflare Merge branch 'main' into chore/merge-upstream-4.5.0 2025-08-20 11:20:31 -03:00
companies Chore/merge upstream 4.8.0 (#150) 2025-11-19 16:25:58 -03:00
contacts Chore/merge upstream 4.8.0 (#150) 2025-11-19 16:25:58 -03:00
enterprise feat(ai): implement dynamic debounce with sidekiq and concurrency locking with redis 2026-03-01 02:04:55 -03:00
internal Merge branch main into chore/merge-upstream 2025-12-20 12:44:31 -03:00
llm feat: add global config for captain settings (#13141) 2026-01-12 19:54:19 +05:30
messages fix(messages): reduce audio transcription 400 retry noise (#13487) 2026-02-17 13:25:13 +05:30
sla chore: fix sla email notifications (#9192) 2024-04-04 21:16:49 +05:30
twilio chore: apply rubocop 2025-09-19 19:44:02 -03:00
voice chore: fix linting 2025-12-20 12:55:27 -03:00
page_crawler_service.rb feat: Response Bot using GPT and Webpage Sources (#7518) 2023-07-21 18:11:51 +03:00