acatighera / statistics Goto Github PK
View Code? Open in Web Editor NEWAn ActiveRecord plugin that makes it easier to do reporting.
License: MIT License
An ActiveRecord plugin that makes it easier to do reporting.
License: MIT License
If I do @campaign.contacts, I get a list of all the contacts.
If I do:
@campaign.contacts.get_stats(:user_count) for example, will it give me the total number of contacts just for that associated campaign?
I have a record called ContactEmail, that has a date_sent attribute.
I want to show the weekly trends. So I would need some kind of output such as [[10/1/2010 => 200], [10/7/2010 => 150], [10/14/2010 => 324]]
What this means is 10/1/2010 contains the sum of all ContactEmails where date_sent is between 10/1/2010 and 1 second before midnight 10/7/2010.
How can I do this with statistics?
When a AR::Base class has a different primary key (not id), this plugin doesn't work.
You must add a parameter :column_name => 'key' when you use define_statistic.
This definition is hardcoded in the file lib/statistics.rb, line 52.
Hi,
is your plugin compatible with rails 3 and 3.1???
This seems great for one-off values, what if I need to create a bar graph, for example, where the x-axis is time?
Here is one solution without statistics that seems cumbersome, but I would imagine statistics could solve it but can't find how:
http://stackoverflow.com/questions/2440957/graphing-new-users-by-date-in-a-rails-app-using-seer
My ideal situation would be a way that I can do a count by date statistic and it outputs an array with date and count so that I can use a plugin like Seer to graph the results....thanks.
I cannot define statistic without also defining filter_all_stats_on.
I get error:
NoMethodError: You have a nil object when you didn't expect it!
The error occurred while evaluating nil.merge
from /Users/alhafoudh/Projects/bankomap.sk/vendor/plugins/statistics/lib/statistics.rb:62:in total_searches_stat' from /Users/alhafoudh/Projects/bankomap.sk/vendor/plugins/statistics/lib/statistics.rb:60:in
each'
from /Users/alhafoudh/Projects/bankomap.sk/vendor/plugins/statistics/lib/statistics.rb:60:in total_searches_stat' from /Users/alhafoudh/Projects/bankomap.sk/vendor/plugins/statistics/lib/statistics.rb:133:in
send'
from /Users/alhafoudh/Projects/bankomap.sk/vendor/plugins/statistics/lib/statistics.rb:133:in `get_stat'
from (irb):6
I tried to do this and it says that there is no column called nil....what is it expecting under conditions?
I am currently using statistics to create an array of key/value pairs around dates and the sums of activity on that date (emails being sent).
I use that information in a graph.
However, on days when the date has 0 activity, there is no key-value pair. So I cannot create a true time-series graph. Is there something in statistics I could do, or would this be in ruby post processing, and if so, how?
It happened in my project . in stead , i use get_stat on relation , still works
Hi, I need to have the array in the following format to work with seer. I want to use statistics rather than manually creating different classes, but this is how it works in seer: How can I assign names in the array?
def report
@DaTa = Widget.all
@Series = @data.map{|w| w.widget_stats}
end
where:
class Widget < ActiveRecord::Base
has_many :widget_stats
def date
self.widget_stats.last.date
end
def quantity
self.widget_stats.last.quantity
end
end
Hi,
Thanks for your contribution on this gem. The idea looks great, I just wondered why this project is not unmaintained anymore, even with some forks. Is there any alternative for this idea?
Thanks
Using Rails 2.3.5 and MySQL 5.1.43
Declaring
define_statistic :average_points, :average => :all
Produces the following SQL
SELECT average(`table_name`.id) AS average_id FROM `table_name`
FUNCTION database.average does not exist
This error is thrown because the MySQL average is avg
not average
The gem should produce SQL like this
SELECT avg(`table_name`.id) AS average_id FROM `table_name`
Either by changing the declaration syntax to use :avg => :all
or by substituting :average
for :avg
in the gem internals
Hi.
I've added your plugin as gem and have defined statistics as
class User < ActiveRecord::Base
define_statistic :users_total, :count => :all
end
but in rails console i see
>> User.statistics
NoMethodError: undefined method `dclone' for {:count=>:all, :column_name=>:id}:Hash
from /opt/local/lib/ruby/gems/1.8/gems/statistics-0.1.1/lib/statistics.rb:64:in `user_total_stat'
from /opt/local/lib/ruby/gems/1.8/gems/statistics-0.1.1/lib/statistics.rb:132:in `send'
from /opt/local/lib/ruby/gems/1.8/gems/statistics-0.1.1/lib/statistics.rb:132:in `statistics'
from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:380:in `inject'
from /opt/local/lib/ruby/gems/1.8/gems/statistics-0.1.1/lib/statistics.rb:131:in `each'
from /opt/local/lib/ruby/gems/1.8/gems/statistics-0.1.1/lib/statistics.rb:131:in `inject'
from /opt/local/lib/ruby/gems/1.8/gems/statistics-0.1.1/lib/statistics.rb:131:in `statistics'
from (irb):3
Could you tell me how to solve this problem? Rails 2.3.5
There is a bug in Rails 2.x where grouping by multiple fields results in wrong values for calculations. I have created a patch for this bug, please encourage the fix by giving feedback or giving +1 plus a short supportive comment. The patch lives here: https://rails.lighthouseapp.com/projects/8994/tickets/5182-activerecordcalculations-returns-incorrect-data-when-grouping-by-multiple-fields.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.