lib/groupdate/series.rb in groupdate-2.1.0 vs lib/groupdate/series.rb in groupdate-2.1.1

- old
+ new

@@ -54,11 +54,16 @@ lambda{|k| k.to_i } else lambda{|k| (k.is_a?(String) ? utc.parse(k) : k.to_time).in_time_zone(@time_zone) } end - count = Hash[ relation.send(method, *args, &block).map{|k, v| [multiple_groups ? k[0...@group_index] + [cast_method.call(k[@group_index])] + k[(@group_index + 1)..-1] : cast_method.call(k), v] } ] + count = + begin + Hash[ relation.send(method, *args, &block).map{|k, v| [multiple_groups ? k[0...@group_index] + [cast_method.call(k[@group_index])] + k[(@group_index + 1)..-1] : cast_method.call(k), v] } ] + rescue NoMethodError + raise "Be sure to install time zone support - https://github.com/ankane/groupdate#for-mysql" + end series = case @field when "day_of_week" 0..6 @@ -126,10 +131,10 @@ else lambda{|k| k } end Hash[series.map do |k| - [key_format.call(k), count[k] || 0] + [multiple_groups ? k[0...@group_index] + [key_format.call(k[@group_index])] + k[(@group_index + 1)..-1] : key_format.call(k), count[k] || 0] end] end def round_time(time) time = time.to_time.in_time_zone(@time_zone) - @day_start.hours