Class: BBNW::NumberOfSourceChanges

Inherits:
Object
  • Object
show all
Extended by:
InvoiceDisplayUtils
Defined in:
lib/adapters/time_estimators/number_of_sources_changes.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
32
33
34
35
36
# File 'lib/adapters/time_estimators/number_of_sources_changes.rb', line 7

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

  activities_span_in_seconds = activities_span * 3600

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

  changes_count    = 0
  meetings.each {|m, time_elapsed| activities_span_in_seconds-=time_elapsed}

  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
    changes_count+=commit.total_changes
  end

  meetings.each {|m,duration|  activities_span_in_seconds-=duration }

  fraction_of_work = activities_span_in_seconds / changes_count

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

  line_items
end