Class: Geostats::Views::FoundsByCacheType

Inherits:
Base
  • Object
show all
Defined in:
lib/geostats/views/founds_by_cache_type.rb

Constant Summary collapse

HEIGHT =
400

Instance Method Summary collapse

Constructor Details

#initializeFoundsByCacheType

Returns a new instance of FoundsByCacheType.



6
7
8
9
10
11
# File 'lib/geostats/views/founds_by_cache_type.rb', line 6

def initialize
  @founds = Stats.founds_by_cache_type
    .select { |a| a[1] > 0 }
    .sort { |a, b| b[1] <=> a[1] }
  @factor = HEIGHT.to_f / @founds.first[1].to_f
end

Instance Method Details

#founds_by_cache_typeObject



13
14
15
16
17
18
19
20
21
# File 'lib/geostats/views/founds_by_cache_type.rb', line 13

def founds_by_cache_type
  @founds.map do |type, count|
    {
      :height => [1, count * @factor].max,
      :founds => count,
      :name   => type.name
    }
  end
end