From e5ed85b7f86c5f2199b2919de7d03b9b47a46d13 Mon Sep 17 00:00:00 2001 From: moveson Date: Sat, 21 Dec 2024 06:27:25 -0700 Subject: [PATCH] Convert durations to Float before computing percentage --- app/view_models/effort_analysis_row.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/view_models/effort_analysis_row.rb b/app/view_models/effort_analysis_row.rb index 3d48e3602..5a581a020 100644 --- a/app/view_models/effort_analysis_row.rb +++ b/app/view_models/effort_analysis_row.rb @@ -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