Code Monkey home page Code Monkey logo

redistat's People

Contributors

jimeh avatar sguha00 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

redistat's Issues

Documentation on interval

I noticed that there is both an interval and a depth option for the finder. What's unclear to me is how those options are meant to be used.

The goal is to be able to find stats and return them aggregated as one number or return them broken out into multiple numbers depending on the size of the time interval used (hourly, daily, yearly). What's the best way to accomplish that?

Intuitively, I'd think that interval would specify the size of the interval returned by the finder. This seems to be the case:

require 'redistat'

class ViewStats
  include Redistat::Model
  depth :hour
end

ViewStats.store('hello', {:world => 4}, 1.hour.ago)
ViewStats.store('hello', {:world => 2}, 3.hours.ago)

ViewStats.find('hello', 1.hour.ago, 1.hour.from_now, :interval => :hour).all
 => [{"world"=>"4"}, {}, {}]

And I'd think that omitting interval would cause the finder to return only one interval. This also seems to be the case:

ViewStats.find('hello', 3.hours.ago, 1.hour.from_now).all
 => [{"world"=>6}]

I would expect that using a year interval would also cause the finder to return only one interval (assuming there had been stats collected in only one year). But this is not the case. The finder behaves as though I used the hour interval:

ViewStats.find('hello', 1.hour.ago, 1.hour.from_now, :interval => :year).all
 => [{"world"=>"4"}, {}, {}] 

I see that the default depth option is :hour, so I thought maybe this was interfering with interval working as expected. Setting depth to :year causes the time range to be ignored:

ViewStats.find('hello', 1.hour.ago, 1.hour.from_now, :interval => :year, :depth => :year).all
 => [{"world"=>"6"}]

So it's unclear to me how these options are meant to be used. Any additional clarity you can provide would be immensely appreciated.

Add an option to have Redistat handle float-based stats for you

Since Redis' atomic increment operations only support integers, any float-based statistics you want to store first need to be converted to an integer, and then back to floats again when you read the stored stats.

The idea is to have Redistat do this conversion for you by telling it which specific stat keys are floats, and with what precision they should be handled. The end result will be that weither you feed Redistat integers or floats, it'll just work.

Problems fetching at boundaries

I've noticed some issues fetching in the last hour of a day, or the last day of a month. There is a query from 23:00 to the following day at 0:00; or from the beginning of the last day of the month to the beginning of the first day of the next month -- in either case, the query returns the following hour (or day) incorrectly. I also noticed that a query from x.beginning_of_day to x.end_of_day will always return nothing (when depth is set to day). Here are the tests I added to finder_spec.rb:

https://gist.github.com/604a6fd34580e472e129

(with corresponding failures)

Add model method to specify the key name.

At the moment it uses the class name in the key name (which is a good default) but there is no easy way to override this. It becomes a problem when you rename your classes. It would be nice to be able to specify a key name in the model.

Fail more gracefully when Redis server is too old

Currently if the Redis server is old and doesn't support hashes, the redis gem will throw an exception when Redistat tries to do a hgetall or hincrby call. This can be handled in a nicer manner.

Example in readme isn't working

I decided to give Redistat a shot today. Unfortunately, I couldn't make it past the example in the readme. I'm on Redis 2.0.4.

  ruby-1.9.2-p136 :015 > class VisitorStats
  ruby-1.9.2-p136 :016?>     include Redistat::Model
  ruby-1.9.2-p136 :017?>   end
   => VisitorStats 
  ruby-1.9.2-p136 :018 > VisitorStats.store('/about', {:views => 1})
   => #<Redistat::Event:0x00000101a14008 @raw_options={}, @options={:depth=>:hour, :store_event=>false, :connection_ref=>nil, :enable_grouping=>true, :label_indexing=>true}, @key=VisitorStats//about:2011031511, @stats={:views=>1}, @meta={}, @new=false> 
  ruby-1.9.2-p136 :019 > stats = VisitorStats.fetch('/about', 2.hour.ago, Time.now)
   => [{}] 
  ruby-1.9.2-p136 :020 > stats.total
   => {}

Add support for non-time based statistics.

Currently all statistics stored with Redistat are assumed to be time-based. Meaning the time of when the event occurs is import and stored.

However for simpler, pure-counter based statistics where when something happened doesn't matter currently is not possible in a simple manner without causing a lot of overhead in the library and Redis.

Add support for average/mean calculations

Let Redistat handle the average/mean calculations for specific values. This should be easy to implement by simply having Redistat count the number of times a specific value has been updated.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.