Class: Turnstile::Observer

Inherits:
Object
  • Object
show all
Defined in:
lib/turnstile/observer.rb

Instance Method Summary collapse

Instance Method Details

#statsObject



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/turnstile/observer.rb', line 10

def stats
  data      = adapter.fetch
  platforms = Hash[data.group_by { |d| d[:platform] }.map { |k, v| [k, sampler.extrapolate(v.count)] }]
  total     = platforms.values.inject(:+) || 0
  Stats.new({
              stats: {
                total:     total,
                platforms: platforms
              },
              users: data
            })
end