Class: Snapstats::EventReader::Activity
- Inherits:
-
Object
- Object
- Snapstats::EventReader::Activity
- Defined in:
- lib/event_reader/event_reader.rb
Class Method Summary collapse
Class Method Details
.fetch(from = 0, to = Time.now) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/event_reader/event_reader.rb', line 19 def self.fetch from=0, to=Time.now Snapstats.redis.zrangebyscore(Snapstats.mday("activity"), from.to_i, to.to_i).map do |i| v = JSON.parse(i, :symbolize_names => true) self.new(email: v[:email], path: v[:path], controller: v[:ctrl], action: v[:actn], runtimes: v[:rntm], os: v[:os], browser: v[:brwsr], version: v[:brver], ip: v[:ip], render_time: v[:total], date: Time.at(v[:date].to_i)) end end |
.fetch_all_chart ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/event_reader/event_reader.rb', line 37 def self.fetch_all_chart # after 5 minutes i forgot how it works fetch(Time.now.beginning_of_day).map{ |i| i.runtimes.reduce({}){ |sum, (k,v)| sum[k] = { value: v, date: i.date.to_i }; sum } }.reduce({}){ |sum, i| i.keys.each{ |rt| sum[rt].present? ? sum[rt] << i[rt] : sum[rt] = [ i[rt] ] } sum } end |