From 88d03239712bdcc214aa007345196f37ccb57f37 Mon Sep 17 00:00:00 2001 From: Toshi MARUYAMA Date: Wed, 2 Jan 2013 21:14:03 +0900 Subject: [PATCH] fix Ruby 1.8.7 compatibility 8e58b6663a0 has some bugs. * Dividing by 100 and 1000. These should by 100.0 and 1000.0. * Ruby 1.8.7 hash is not orderd. --- app/views/ratios/_bottom_js.html.erb | 4 ++-- lib/indicators_logic.rb | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/views/ratios/_bottom_js.html.erb b/app/views/ratios/_bottom_js.html.erb index 7dc59ac..7781abc 100644 --- a/app/views/ratios/_bottom_js.html.erb +++ b/app/views/ratios/_bottom_js.html.erb @@ -24,7 +24,7 @@ // Create and populate the data table. var data_gauge = new google.visualization.arrayToDataTable([ ['Label', 'Value'], - ['CPI', <%= raw (@proj_or_vers_indicators[1] * 1000).to_f.round / 1000 %>] + ['CPI', <%= (@proj_or_vers_indicators[1] * 1000).round / 1000.0 %>] ]); var options_g = { redFrom: 0, redTo: 0.85, @@ -42,7 +42,7 @@ // Create and populate the data table. var data_gauges = new google.visualization.arrayToDataTable([ ['Label', 'Value'], - ['SPI', <%= raw (@proj_or_vers_indicators[2] * 1000).to_f.round / 1000 %>] + ['SPI', <%= (@proj_or_vers_indicators[2] * 1000).round / 1000.0 %>] ]); var options_gs = { redFrom: 0, redTo: 0.85, diff --git a/lib/indicators_logic.rb b/lib/indicators_logic.rb index b9f9da2..2a5c1de 100644 --- a/lib/indicators_logic.rb +++ b/lib/indicators_logic.rb @@ -55,7 +55,8 @@ def self.calc_indicators(my_project_or_version, ary_reported_time_week_year, ary sum_real = 0 sum_planned = 0 sum_earned = 0 - hash_weeks_years.each do |k,v| + ary_weeks_years.each do |k| + v = hash_weeks_years[k] sum_real += ary_reported_time_week_year.has_key?(k)? ary_reported_time_week_year[k] : 0 v[0] = sum_real sum_planned += v[1] @@ -64,9 +65,9 @@ def self.calc_indicators(my_project_or_version, ary_reported_time_week_year, ary v[2] = sum_earned @ary_data_week_years.push( Array[k[0].to_s + "/" + k[1].to_s, - ((v[0] * 100).to_f).round / 100, - ((v[1] * 100).to_f).round / 100, - ((v[2] * 100).to_f).round / 100]) + (v[0] * 100).round / 100.0, + (v[1] * 100).round / 100.0, + (v[2] * 100).round / 100.0]) end @cpi = hash_weeks_years.values.last[0].zero? ? 0 : hash_weeks_years.values.last[2]/hash_weeks_years.values.last[0] @spi = hash_weeks_years.values.last[1].zero? ? 0 : hash_weeks_years.values.last[2]/hash_weeks_years.values.last[1]