Module: Eye::Group::Data

Included in:
Eye::Group
Defined in:
lib/eye/group/data.rb

Instance Method Summary collapse

Instance Method Details

#debug_dataObject



36
37
38
# File 'lib/eye/group/data.rb', line 36

def debug_data
  { queue: scheduler_commands_list, chain: chain_status }
end

#status_data(opts = {}) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/eye/group/data.rb', line 3

def status_data(opts = {})
  plist = @processes.map { |p| p.status_data(opts) }

  h = { name: name, type: :group, subtree: plist }

  h[:debug] = debug_data if opts[:debug]

  # show current chain
  if scheduled_call = @scheduled_call
    h[:current_command] = scheduled_call[:command]

    if (chain_commands = scheduler_commands_list) && chain_commands.present?
      h[:chain_commands] = chain_commands
    end

    if @chain_processes_current && @chain_processes_count
      h[:chain_progress] = [@chain_processes_current, @chain_processes_count]
    end
  end

  h
end

#status_data_shortObject



26
27
28
29
30
31
32
33
34
# File 'lib/eye/group/data.rb', line 26

def status_data_short
  h = {}
  @processes.each do |p|
    state = p.state
    h[state] ||= 0
    h[state] += 1
  end
  { name: (@name == '__default__' ? 'default' : @name), type: :group, states: h }
end