Consolida o trabalho desta branch de abril/2026 em um bloco pronto pra testar em staging antes do merge pra main. ## Correções de memória semântica - ExtractionService: Princípio Zero + Regra de Ouro (ação consumada vs intenção). - Cenário Daniela_Reservas: Passo 0 de classificação (consulta/intenção/fora). ## Roleta da Sorte (end-to-end) - Schema Supabase + 7 RPCs atômicas (server-side, idempotentes). - Services: Offer, Redeem, WeeklyReport. - Jobs: OfferRouletteJob (hook em ConfirmationService após Pix pago), NotifyRevealed + Scheduler de fallback. - Tool manual GenerateRoletaLinkTool + endpoint público /roleta/notify. - Dashboard /captain/roleta com Resgate + Relatório + anomaly detection. ## Cenário Reclamacoes_Ouvidoria - Triagem P1-P4, framework LAST, Three-level listening, Self-check. - Sem compensação material, detecção de cliente frustrado eleva prioridade. ## Analytics - Funil de conversão /captain/funnel: 5 etapas via regex, zero LLM. - Detector de churn via ChurnOutreach* (cron dias úteis 10h-17h BRT). ## Trabalho pré-existente incluído - Captain Executive Reports (ceo_digest, mattermost_delivery). - get_reserva_preco_tool, Lifecycle ajustes, Reservations UI polimentos. ## Outros - .gitignore: patterns pra credenciais. - Migrations de scenarios idempotentes. - i18n completa pt_BR+en pra roleta/funnel. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
43 lines
1.8 KiB
Ruby
43 lines
1.8 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
# == Schema Information
|
|
#
|
|
# Table name: captain_lifecycle_configs
|
|
#
|
|
# id :bigint not null, primary key
|
|
# min_interval_minutes :integer default(30), not null
|
|
# pause_on_customer_reply :boolean default(FALSE), not null
|
|
# pause_on_customer_reply_within_minutes :integer default(60), not null
|
|
# quiet_hours_enabled :boolean default(FALSE), not null
|
|
# quiet_hours_from :time default(Sat, 01 Jan 2000 23:00:00.000000000 UTC +00:00), not null
|
|
# quiet_hours_to :time default(Sat, 01 Jan 2000 08:00:00.000000000 UTC +00:00), not null
|
|
# created_at :datetime not null
|
|
# updated_at :datetime not null
|
|
# account_id :bigint not null
|
|
# opt_out_label_id :bigint
|
|
#
|
|
# Indexes
|
|
#
|
|
# index_captain_lifecycle_configs_on_account_id (account_id) UNIQUE
|
|
# index_captain_lifecycle_configs_on_opt_out_label_id (opt_out_label_id)
|
|
#
|
|
# Foreign Keys
|
|
#
|
|
# fk_rails_... (account_id => accounts.id)
|
|
# fk_rails_... (opt_out_label_id => labels.id)
|
|
#
|
|
class Captain::Lifecycle::Config < ApplicationRecord
|
|
self.table_name = 'captain_lifecycle_configs'
|
|
|
|
belongs_to :account
|
|
belongs_to :opt_out_label, class_name: 'Label', optional: true
|
|
|
|
validates :account_id, uniqueness: true
|
|
validates :min_interval_minutes, numericality: { greater_than_or_equal_to: 0 }
|
|
validates :pause_on_customer_reply_within_minutes, numericality: { greater_than_or_equal_to: 0 }
|
|
|
|
def self.for_account(account)
|
|
find_or_create_by!(account_id: account.id)
|
|
end
|
|
end
|