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>
74 lines
2.7 KiB
Ruby
74 lines
2.7 KiB
Ruby
# == Schema Information
|
|
#
|
|
# Table name: captain_units
|
|
#
|
|
# id :bigint not null, primary key
|
|
# concierge_config :jsonb not null
|
|
# inter_account_number :string
|
|
# inter_cert_content :text
|
|
# inter_cert_path :string
|
|
# inter_client_secret :string
|
|
# inter_key_content :text
|
|
# inter_key_path :string
|
|
# inter_pix_key :string
|
|
# last_synced_at :datetime
|
|
# leader_whatsapp :string
|
|
# name :string not null
|
|
# payment_receipt_review_enabled :boolean default(FALSE), not null
|
|
# plug_play_token :string
|
|
# proactive_pix_polling_enabled :boolean default(FALSE), not null
|
|
# reservation_source_tag :string
|
|
# reservations_sync_enabled :boolean
|
|
# status :string
|
|
# suite_category_images :jsonb not null
|
|
# visible_suite_categories :jsonb not null
|
|
# webhook_configured_at :datetime
|
|
# webhook_url :string
|
|
# created_at :datetime not null
|
|
# updated_at :datetime not null
|
|
# account_id :bigint not null
|
|
# captain_brand_id :bigint not null
|
|
# concierge_inbox_id :bigint
|
|
# inbox_id :bigint
|
|
# inter_client_id :string
|
|
# plug_play_id :string
|
|
#
|
|
# Indexes
|
|
#
|
|
# index_captain_units_on_account_id (account_id)
|
|
# index_captain_units_on_captain_brand_id (captain_brand_id)
|
|
# index_captain_units_on_concierge_inbox_id (concierge_inbox_id)
|
|
# index_captain_units_on_inbox_id (inbox_id)
|
|
#
|
|
# Foreign Keys
|
|
#
|
|
# fk_rails_... (account_id => accounts.id)
|
|
# fk_rails_... (captain_brand_id => captain_brands.id)
|
|
# fk_rails_... (concierge_inbox_id => inboxes.id)
|
|
# fk_rails_... (inbox_id => inboxes.id)
|
|
#
|
|
|
|
class Captain::Unit < ApplicationRecord
|
|
belongs_to :account
|
|
# belongs_to :captain_brand, class_name: 'Captain::Brand', optional: true
|
|
|
|
encrypts :inter_client_secret, :inter_cert_content, :inter_key_content
|
|
|
|
validates :name, presence: true
|
|
validates :inter_pix_key, presence: true, on: :update
|
|
validates :inter_account_number, presence: true, on: :update
|
|
|
|
# Atributos resolvidos que o controller já espera ter, fallback na necessidade para arquivos (mesmo não sendo mais o padrão preferido).
|
|
def resolved_inter_cert_path
|
|
return nil if inter_cert_content.present?
|
|
|
|
inter_cert_path
|
|
end
|
|
|
|
def resolved_inter_key_path
|
|
return nil if inter_key_content.present?
|
|
|
|
inter_key_path
|
|
end
|
|
end
|