This bug was caused when the chart encountered data outside of its
visible range (i.e., the upper bound of the array size). A test was
added that inserts some data from 2 years and 16 months in the past.
The test failed on the old version, throwing exactly the error in bug
report #1442.

The fix is to check whether or not the value is within the array range
before sending the "+=" operator. With this change, the test passes.
This commit is contained in:
Don Cruse 2013-07-28 19:00:51 -05:00
parent 58e0393efa
commit 8ed20b35f2
2 changed files with 23 additions and 1 deletions

View file

@ -377,7 +377,7 @@ class StatsController < ApplicationController
# the block should return an array of indexes each is added to the hash and summed
def convert_to_array(records, upper_bound)
a = Array.new(upper_bound, 0)
records.each { |r| (yield r).each { |i| a[i] += 1 } }
records.each { |r| (yield r).each { |i| a[i] += 1 if a[i] } }
a
end