Class: Symian::Incident

Inherits:
Object
  • Object
show all
Includes:
YAMLSerializable
Defined in:
lib/symian/incident.rb

Constant Summary collapse

MIN_PRIORITY =

priorities are not currently used

0
MAX_PRIORITY =
9
REQUIRED_ATTRIBUTES =
[
  :iid,                     # incident ID
  :arrival_time,            # time of incident arrival at the IT support organization
]
OTHER_ATTRIBUTES =
[
  :category,                # incident category
# :severity,                # incident severity - not implemented yet
# :state,                   # incident state - not implemented yet
  :priority,                # incident priority - not currently used
  :visited_support_groups,  # number of visited SGs
# :needed_work_time,        # needed work time before incident escalation
#                           #   - initialized at the arrival in a support group
#                           #   - decreased as operator works on the incident
#                           #   - when it reaches 0, the incident is escalated
  :start_work_time,         # time when the first operator starts working on the incident
                            #   - set in Operator#assign
# :total_work_time,         # total work time on the incident
#                           #   - initialized to 0 in the constructor
# :total_queue_time,        # total time spent waiting for an operator
#                           #   - initialized to 0 in the constructor
# :total_suspension_time,   # total suspension time
#                           #   - initialized to 0 in the constructor
  :closure_time,            # time at which the incident was closed
]
TRACED_ATTRIBUTES =
REQUIRED_ATTRIBUTES + OTHER_ATTRIBUTES + [ :tracking_information ]

Instance Method Summary collapse

Methods included from YAMLSerializable

#to_yaml_properties

Constructor Details

#initialize(iid, arrival_time, opts = {}) ⇒ Incident

Returns a new instance of Incident.



47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/symian/incident.rb', line 47

def initialize(iid, arrival_time, opts={})
  @iid = iid
  @arrival_time = arrival_time

  # set correspondent instance variables for optional arguments
  opts.each do |k, v|
    # ignore invalid attributes
    instance_variable_set("@#{k}", v) if OTHER_ATTRIBUTES.include?(k)
  end

  @tracking_information ||= []
  @visited_support_groups ||= 0
end

Instance Method Details

#add_tracking_information(track_info) ⇒ Object

the format of track_info is: { :type => one of [ :queue, :work, :suspend ]

:at => begin time
:duration => duration
:sg => support_group_name
:operator => operator_id (if applicable)

}



69
70
71
# File 'lib/symian/incident.rb', line 69

def add_tracking_information(track_info)
  @tracking_information << track_info
end

#closed?Boolean

Returns:

  • (Boolean)


105
106
107
# File 'lib/symian/incident.rb', line 105

def closed?
  !@closure_time.nil?
end

#queue_time_at_last_sgObject



101
102
103
# File 'lib/symian/incident.rb', line 101

def queue_time_at_last_sg
  calculate_time_at_last_support_group(:queue)
end

#total_queue_timeObject



89
90
91
# File 'lib/symian/incident.rb', line 89

def total_queue_time
  calculate_time(:queue)
end

#total_suspend_timeObject



93
94
95
# File 'lib/symian/incident.rb', line 93

def total_suspend_time
  calculate_time(:suspend)
end

#total_time_at_last_sgObject



97
98
99
# File 'lib/symian/incident.rb', line 97

def total_time_at_last_sg
  calculate_time_at_last_support_group(:all)
end

#total_work_timeObject



85
86
87
# File 'lib/symian/incident.rb', line 85

def total_work_time
  calculate_time(:work)
end

#ttrObject



109
110
111
112
# File 'lib/symian/incident.rb', line 109

def ttr
  # if incident isn't closed yet, just return nil without raising an exception.
  @closure_time.nil? ? nil : (@closure_time - @arrival_time).to_int
end

#with_tracking_information(type = :all) ⇒ Object



73
74
75
76
77
78
79
80
81
82
83
# File 'lib/symian/incident.rb', line 73

def with_tracking_information(type=:all)
  selected_ti = if type == :all
    @tracking_information
  else
    @tracking_information.select{|el| el.type == type }
  end

  selected_ti.each do |ti|
    yield ti
  end
end