Class: GitWakaTime::Timer
- Inherits:
-
Object
- Object
- GitWakaTime::Timer
- Defined in:
- lib/gitwakatime/timer.rb
Overview
Integrates the nested hash from mapper with heartbeats api
Instance Method Summary collapse
-
#initialize(commits, heartbeats_with_durations) ⇒ Timer
constructor
A new instance of Timer.
- #process ⇒ Object
- #total ⇒ Object
- #total_commited ⇒ Object
Constructor Details
#initialize(commits, heartbeats_with_durations) ⇒ Timer
Returns a new instance of Timer.
9 10 11 12 |
# File 'lib/gitwakatime/timer.rb', line 9 def initialize(commits, heartbeats_with_durations) @commits = commits @heartbeats_with_durations = heartbeats_with_durations end |
Instance Method Details
#process ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/gitwakatime/timer.rb', line 26 def process @commits_with_duration = @commits.each do |commit| if commit.commited_files.count > 0 || commit.parent_sha commit.commited_files.each_with_index do |file, _i| time = sum_heartbeats relevant_heartbeats(commit, file) file.time_in_seconds = time commit.time_in_seconds = time file.save end commit.save else commit.time_in_seconds = sum_heartbeats( heartbeats_before(@heartbeats_with_durations, commit.date) ) end end.compact total total_commited @commits_with_duration.group_by { |c| c.date.to_date } end |