Did you know that you can navigate the posts by swiping left and right?
Clients for whom I worked, at some stage of the are almost always asked me to create statistics describing the status and dynamics of development. The simplest example is number of registered users, but with time it always get more complex.
I decided to build a small library in order to have common way of defining the statistics among my projects. Gem statistics gives not enough freedom to me. I need to be able to define reports having complex row definitions and reports made of other reports.
First I developed gem with ActionMailer support (with simple report email), but recently my another client asked me for statistics in rails 2.3.x project. Then problems with compatibility came up, so I decided to remove ActionMailer support completely. The gem delivers only possibility to build reports as ruby objects now. You should create views for those on your own.
You can get report by instantiating report class
Each value is cached after calculation while report object exists.
Calling report methods will trigger calculation and return
KPI::Report provides enumerator
#entries allowing to iterate through report entries:
In order to get report for previous day, you should pass :time option to report initializer:
NOTE: In entry definitions you should not use
Time.now for determining
current time, use
There is another class
KPI::MergedReport. It takes reports of the same type and merges them using function passed through block:
NOTE: For now unfortunately it is not possible to use result helper in that block. I am working on that.
Now, we can get differences between reports:
Actually it is not problem to pass more reports and calculate average value for example:
When you have your report object, you might want to send an email with data provided by it or do something else. That’s all for now. Check it out on Github! All ideas and comments are welcome!