module RRRSpec::Server::JSONConstructor::TasksetJSONConstructor

Public Instance Methods

as_full_json() click to toggle source
# File lib/rrrspec/server/json_constructor.rb, line 20
def as_full_json
  h = as_json(except: :id, methods: :log)
  h['slaves'] = slaves.map(&:as_full_json)
  h['tasks'] = tasks.map(&:as_full_json)
  h['worker_logs'] = worker_logs.map(&:as_full_json)
  h
end
as_json_for_index() click to toggle source
# File lib/rrrspec/server/json_constructor.rb, line 28
def as_json_for_index
  {
    'id' => id,
    'key' => key,
    'rsync_name' => rsync_name,
    'setup_command' => setup_command,
    'slave_command' => slave_command,
    'worker_type' => worker_type,
    'max_workers' => max_workers,
    'max_trials' => max_trials,
    'taskset_class' => taskset_class,
    'created_at' => created_at,
    'status' => status,
    'finished_at' => finished_at,
  }
end
as_json_for_result_page() click to toggle source
# File lib/rrrspec/server/json_constructor.rb, line 45
def as_json_for_result_page
  as_json_for_index.merge(
    'tasks' => tasks.map(&:as_json_for_result_page),
  )
end
as_nodetail_json() click to toggle source
# File lib/rrrspec/server/json_constructor.rb, line 8
def as_nodetail_json
  as_json(except: :id, methods: :log)
end
as_short_json() click to toggle source
# File lib/rrrspec/server/json_constructor.rb, line 12
def as_short_json
  h = as_json(except: :id, methods: :log)
  h['slaves'] = slaves.map { |slave| slave.as_json(only: :key) }
  h['tasks'] = tasks.map { |task| task.as_json(only: :key) }
  h['worker_logs'] = worker_logs.map { |worker_log| worker_log.as_json(only: :key) }
  h
end
as_summary_json() click to toggle source
# File lib/rrrspec/server/json_constructor.rb, line 51
def as_summary_json
  statuses = tasks.pluck(:status)
  groups = statuses.group_by { |status| status }
  groups.default = []

  {
    'id' => id,
    'key' => key,
    'status' => status,
    'created_at' => created_at,
    'finished_at' => finished_at,
    'task_count' => statuses.count,
    'passed_count' => groups['passed'].size,
    'pending_count' => groups['pending'].size,
    'failed_count' => groups['failed'].size,
  }
end