Skip to content

Commit

Permalink
Merge pull request #2 from waissbluth/fix-bucket-size
Browse files Browse the repository at this point in the history
Fix bucket size calculation
  • Loading branch information
waissbluth authored Feb 4, 2020
2 parents 94d731c + 6a4399e commit 62c1470
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions lib/pg_histogram/histogram.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def initialize(query, column_name, options = {})
@min = options[:min] || 0
@max = options[:max]
@buckets = options[:buckets]
@bucket_size = calculate_bucket_size
@bucket_size = (@max - @min).to_f / @buckets
else
@min = options[:min]
@max = options[:max]
Expand Down Expand Up @@ -60,10 +60,6 @@ def source_max
@source_max ||= subquery.maximum(pure_column(true))
end

def calculate_bucket_size
(source_max - source_min).to_f / @buckets
end

def num_buckets
@buckets ||= ((max - min) / bucket_size).to_i
end
Expand Down

0 comments on commit 62c1470

Please sign in to comment.