Module: Models::EmployeeWatchList
- Extended by:
- ActiveSupport::Concern
- Included in:
- Employee
- Defined in:
- app/concerns/models/employee_watch_list.rb
Overview
Watch-list and monitoring-group management for Employee.
Instance Method Summary collapse
-
#effective_watch_list_ids(include_role_list: true) ⇒ Array<Integer>
All employee IDs this employee effectively watches.
-
#monitor_group_sms_numbers=(val) ⇒ Boolean
Sets whether monitor-group SMS numbers are included for this employee.
-
#monitor_unlinked_extensions=(val) ⇒ Boolean
Sets whether calls on unlinked extensions are monitored for this employee.
-
#selected_queue_coverage_ids ⇒ Array<Integer>
Phone queues this employee last chose on the queue coverage dashboard.
-
#selected_queue_coverage_ids=(val) ⇒ Hash
Persists the employee's queue coverage selection in their preferences.
-
#selected_watch_list_employee_ids ⇒ Array<Integer>
IDs of the individual employees on this employee's watch list.
-
#selected_watch_list_employee_ids=(val) ⇒ Array<Integer>
Replaces the employees on this employee's watch list.
-
#selected_watch_list_role_ids ⇒ Array<Integer>
IDs of the roles this employee selected for their watch list.
-
#selected_watch_list_role_ids=(val) ⇒ Array<Integer>
Replaces the employee's selected watch-list roles.
-
#selected_watch_list_roles_employees ⇒ ActiveRecord::Relation<Employee>
Active employees covered by the selected watch-list roles.
-
#watch_list ⇒ ActiveRecord::Relation<Employee>
Employees available to add to a watch list.
Instance Method Details
#effective_watch_list_ids(include_role_list: true) ⇒ Array<Integer>
All employee IDs this employee effectively watches.
74 75 76 77 78 79 80 |
# File 'app/concerns/models/employee_watch_list.rb', line 74 def effective_watch_list_ids(include_role_list: true) list = [] list += selected_watch_list_roles_employees.ids if include_role_list && selected_watch_list_role_ids.present? list += selected_watch_list_employee_ids list << id if list.empty? list.uniq end |
#monitor_group_sms_numbers=(val) ⇒ Boolean
Sets whether monitor-group SMS numbers are included for this employee.
86 87 88 |
# File 'app/concerns/models/employee_watch_list.rb', line 86 def monitor_group_sms_numbers=(val) employee_record.monitor_group_sms_numbers = val || false end |
#monitor_unlinked_extensions=(val) ⇒ Boolean
Sets whether calls on unlinked extensions are monitored for this employee.
94 95 96 |
# File 'app/concerns/models/employee_watch_list.rb', line 94 def monitor_unlinked_extensions=(val) employee_record.monitor_unlinked_extensions = val || false end |
#selected_queue_coverage_ids ⇒ Array<Integer>
Phone queues this employee last chose on the queue coverage dashboard.
An empty array is intentional: first-time visitors start with no queue
selected, and turning the final queue off must remain sticky.
53 54 55 |
# File 'app/concerns/models/employee_watch_list.rb', line 53 def selected_queue_coverage_ids normalize_queue_coverage_ids(employee_record&.heatwave_preferences&.dig('queue_coverage_queue_ids')) end |
#selected_queue_coverage_ids=(val) ⇒ Hash
Persists the employee's queue coverage selection in their preferences.
62 63 64 65 66 |
# File 'app/concerns/models/employee_watch_list.rb', line 62 def selected_queue_coverage_ids=(val) preferences = (employee_record.heatwave_preferences || {}).dup preferences['queue_coverage_queue_ids'] = normalize_queue_coverage_ids(val) employee_record.heatwave_preferences = preferences end |
#selected_watch_list_employee_ids ⇒ Array<Integer>
IDs of the individual employees on this employee's watch list.
35 36 37 |
# File 'app/concerns/models/employee_watch_list.rb', line 35 def selected_watch_list_employee_ids employee_record&.watch_list_ids || [] end |
#selected_watch_list_employee_ids=(val) ⇒ Array<Integer>
Replaces the employees on this employee's watch list.
43 44 45 |
# File 'app/concerns/models/employee_watch_list.rb', line 43 def selected_watch_list_employee_ids=(val) employee_record.watch_list_ids = (val || []).compact.uniq end |
#selected_watch_list_role_ids ⇒ Array<Integer>
IDs of the roles this employee selected for their watch list.
11 12 13 |
# File 'app/concerns/models/employee_watch_list.rb', line 11 def selected_watch_list_role_ids employee_record&.watch_list_role_ids || [] end |
#selected_watch_list_role_ids=(val) ⇒ Array<Integer>
Replaces the employee's selected watch-list roles.
19 20 21 |
# File 'app/concerns/models/employee_watch_list.rb', line 19 def selected_watch_list_role_ids=(val) employee_record.watch_list_role_ids = (val || []).compact.uniq end |
#selected_watch_list_roles_employees ⇒ ActiveRecord::Relation<Employee>
Active employees covered by the selected watch-list roles.
27 28 29 |
# File 'app/concerns/models/employee_watch_list.rb', line 27 def selected_watch_list_roles_employees Employee.active_employees.joins(account: :roles).where(roles: { id: selected_watch_list_role_ids }) end |
#watch_list ⇒ ActiveRecord::Relation<Employee>
Employees available to add to a watch list.
101 102 103 |
# File 'app/concerns/models/employee_watch_list.rb', line 101 def watch_list Employee.active_employees.sorted end |