Skip to content

Commit

Permalink
Merge pull request #1358 from SplitTime/oveson/fix-active-support-dur…
Browse files Browse the repository at this point in the history
…ation-comparison-problem

Convert durations to Float before computing percentage
  • Loading branch information
moveson authored Dec 21, 2024
2 parents 89d02f9 + e5ed85b commit 500c70c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions app/view_models/effort_analysis_row.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,16 @@ def time_in_aid_over_under(round_to: 1.second)
end

def combined_time_over_under(round_to: 1.second)
return nil unless segment_time_over_under && time_in_aid_over_under
return nil unless segment_time_over_under.present? && time_in_aid_over_under.present?

segment_time_over_under.round_to_nearest(round_to) + time_in_aid_over_under.round_to_nearest(round_to)
end

# @return [Float, nil]
def segment_over_under_percent
segment_time_over_under && segment_time_typical && segment_time_over_under / segment_time_typical
return nil unless segment_time_over_under.present? && segment_time_typical.present?

segment_time_over_under.to_f / segment_time_typical.to_f
end

private
Expand Down

0 comments on commit 500c70c

Please sign in to comment.