Class: BBNW::NumberOfSourceCommits

Inherits:
Object
  • Object
show all
Extended by:
InvoiceDisplayUtils
Defined in:
lib/adapters/time_estimators/number_of_source_commits.rb

Class Method Summary collapse

Methods included from InvoiceDisplayUtils

company, display_price, header, message_display

Methods included from DateTimeUtils

#is_number?, #long_date, #long_date_time, #long_time, #parse_time, #short_date, #short_time, #time_description

Class Method Details

.line_items(activities_span, repository_adapter, meetings = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/adapters/time_estimators/number_of_source_commits.rb', line 7

def self.line_items(activities_span, repository_adapter, meetings = {})
  line_items                 = {}
  task_ids_commits           = {}

  activities_span_in_seconds = activities_span * 3600
  meetings.each {|m, time_elapsed| activities_span_in_seconds-=time_elapsed}

  commits    = repository_adapter.commits
  return line_items if commits.size == 0

  commits.each do |commit|
    task_id = commit.task_id
    task_id = short_date(commit.timestamp) if task_id.nil?
    task_ids_commits[task_id]||=[]
    task_ids_commits[task_id] << commit
  end

  fraction_of_work = activities_span_in_seconds / commits.size

  task_ids_commits.each do |task_id, task_commits|
    task_commits.each {|tc| line_items[tc] = fraction_of_work }
  end

  line_items
end