Class: PhoneQueueOrderChange
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- PhoneQueueOrderChange
- Defined in:
- app/models/phone_queue_order_change.rb
Overview
Audit record: one phone-queue ring-order change.
Written by EmployeePhoneStatusesController#update_queue_order (manual drag
on the switchboard, +source+ 'manual', +employee+ set), by
RotatePhoneQueuesWorker (weekly rotation, +source+ 'worker'), and by
PullPhoneQueueStatusWorker's drift check (order changed directly in
Switchvox, +source+ 'external-switchvox'). +previous_order+ / +new_order+
hold the Switchvox member account ids in ring order before and after the
change. Append-only — this IS the audit trail, so no Models::Auditable here.
Constant Summary collapse
- SOURCES =
Allowed sources for an order change.
%w[manual worker external-switchvox].freeze
Constants included from Models::Schedulable
Models::Schedulable::SIMPLE_FORM_OPTIONS
Instance Attribute Summary collapse
-
#queue_account_id ⇒ String
Switchvox queue account id.
-
#source ⇒ String
How the change originated.
Belongs to collapse
Instance Method Summary collapse
-
#actor_name ⇒ String
Who or what made the change, for display.
-
#external? ⇒ Boolean
True when the order was changed directly in Switchvox (detected by PullPhoneQueueStatusWorker's drift check).
-
#source_label ⇒ String
Short badge label for the change source.
-
#worker? ⇒ Boolean
True when the weekly rotation worker made the change.
Methods inherited from ApplicationRecord
ransackable_associations, ransackable_attributes, ransackable_scopes, ransortable_attributes, #to_relation
Methods included from Models::Schedulable
Methods included from Models::AfterCommittable
Methods included from Models::EventPublishable
Instance Attribute Details
#queue_account_id ⇒ String
Returns Switchvox queue account id.
21 |
# File 'app/models/phone_queue_order_change.rb', line 21 validates :queue_account_id, presence: true, inclusion: { in: PhoneQueue::REGISTRY.keys } |
#source ⇒ String
Returns How the change originated.
24 |
# File 'app/models/phone_queue_order_change.rb', line 24 validates :source, presence: true, inclusion: { in: SOURCES } |
Instance Method Details
#actor_name ⇒ String
Returns who or what made the change, for display.
50 51 52 53 54 55 56 57 58 |
# File 'app/models/phone_queue_order_change.rb', line 50 def actor_name if worker? 'Weekly rotation' elsif external? 'Switchvox (direct edit)' else employee&.full_name.to_s end end |
#employee ⇒ Employee
Validations (if => -> { source == 'manual' } ):
17 |
# File 'app/models/phone_queue_order_change.rb', line 17 belongs_to :employee, optional: true |
#external? ⇒ Boolean
Returns true when the order was changed directly in Switchvox
(detected by PullPhoneQueueStatusWorker's drift check).
34 35 36 |
# File 'app/models/phone_queue_order_change.rb', line 34 def external? source == 'external-switchvox' end |
#source_label ⇒ String
Returns short badge label for the change source.
39 40 41 42 43 44 45 46 47 |
# File 'app/models/phone_queue_order_change.rb', line 39 def source_label if worker? 'auto' elsif external? 'external' else 'manual' end end |
#worker? ⇒ Boolean
Returns true when the weekly rotation worker made the change.
28 29 30 |
# File 'app/models/phone_queue_order_change.rb', line 28 def worker? source == 'worker' end |