Class: Afterburn::ListIntervalSeries

Inherits:
Object
  • Object
show all
Defined in:
lib/afterburn/list_interval_series.rb

Instance Method Summary collapse

Constructor Details

#initialize(lists, timestamps) ⇒ ListIntervalSeries

Returns a new instance of ListIntervalSeries.



6
7
8
# File 'lib/afterburn/list_interval_series.rb', line 6

def initialize(lists, timestamps)
  @lists, @timestamps = lists, timestamps
end

Instance Method Details

#aggregate(lists, opts = {}) ⇒ Object



17
18
19
20
# File 'lib/afterburn/list_interval_series.rb', line 17

def aggregate(lists, opts = {})
  vectors = lists.map { |list| list.timestamp_count_vector(@timestamps) }
  [{ "name" => opts[:name], "data" => vectors.inject(&:+).to_a }]
end

#backlog_listsObject



28
29
30
# File 'lib/afterburn/list_interval_series.rb', line 28

def backlog_lists
  @lists.select { |list| list.role == List::Role::BACKLOG }
end

#deployed_listsObject



36
37
38
# File 'lib/afterburn/list_interval_series.rb', line 36

def deployed_lists
  @lists.select { |list| list.role == List::Role::DEPLOYED }
end

#map(lists) ⇒ Object



22
23
24
25
26
# File 'lib/afterburn/list_interval_series.rb', line 22

def map(lists)
  lists.map do |list|
    { "name" => list.name, "data" => list.timestamp_count_vector(@timestamps).to_a } 
  end
end

#to_jsonObject

deploy_list_counts + wip_list_counts + completed_list_counts



11
12
13
14
15
# File 'lib/afterburn/list_interval_series.rb', line 11

def to_json
  aggregate(backlog_lists, :name => List::Role::BACKLOG) +
  map(wip_lists) +
  aggregate(deployed_lists, :name => List::Role::DEPLOYED)
end

#wip_listsObject



32
33
34
# File 'lib/afterburn/list_interval_series.rb', line 32

def wip_lists
  @lists.select { |list| list.role == List::Role::WIP }
end