- Adiciona check_in_at/duration_hours ao schema do tool CreateReservationIntent para que a IA capture o horário EXATO de chegada informado pelo cliente - Cria captain_notification_templates: label, content, timing_minutes, timing_direction (before/after), active, position - Implementa SendNotificationService com interpolação de variáveis (guest_name, check_in_time, check_out_time, suite_name, unit_name) - Implementa NotificationScannerJob (Sidekiq-cron a cada 5min) com janela de tolerância de ±5min e idempotência via metadata JSONB - API REST: /captain/units/:unit_id/notification_templates (CRUD) - Store Vuex captainNotificationTemplates + API client - UI: página de gestão de templates com editor inline e botão '+' - Configura rota captain_settings_notifications - i18n PT/EN para todas as strings novas - Rubocop e ESLint: zero offenses
42 lines
1.5 KiB
Ruby
42 lines
1.5 KiB
Ruby
# == Schema Information
|
|
#
|
|
# Table name: captain_notification_templates
|
|
#
|
|
# id :bigint not null, primary key
|
|
# active :boolean default(TRUE), not null
|
|
# content :text not null
|
|
# label :string not null
|
|
# position :integer default(0), not null
|
|
# timing_direction :integer default("before"), not null
|
|
# timing_minutes :integer default(10), not null
|
|
# created_at :datetime not null
|
|
# updated_at :datetime not null
|
|
# captain_unit_id :bigint not null
|
|
#
|
|
# Indexes
|
|
#
|
|
# idx_notif_templates_unit_active (captain_unit_id,active)
|
|
# index_captain_notification_templates_on_captain_unit_id (captain_unit_id)
|
|
#
|
|
# Foreign Keys
|
|
#
|
|
# fk_rails_... (captain_unit_id => captain_units.id)
|
|
#
|
|
class Captain::NotificationTemplate < ApplicationRecord
|
|
self.table_name = 'captain_notification_templates'
|
|
|
|
belongs_to :unit, class_name: 'Captain::Unit', foreign_key: 'captain_unit_id', inverse_of: :notification_templates
|
|
|
|
enum timing_direction: { before: 0, after: 1 }
|
|
|
|
validates :label, presence: true
|
|
validates :content, presence: true
|
|
validates :timing_minutes, presence: true, numericality: { greater_than: 0 }
|
|
validates :timing_direction, presence: true
|
|
validates :captain_unit_id, presence: true
|
|
|
|
scope :active, -> { where(active: true) }
|
|
scope :ordered, -> { order(:position, :id) }
|
|
scope :for_unit, ->(unit_id) { where(captain_unit_id: unit_id) }
|
|
end
|