Git Product home page Git Product logo

statistics's People

Contributors

alhafoudh avatar masterkain 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

statistics's Issues

can I do tested / associations?

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?

:average => :all calls non existent MySQL function average instead of *avg*

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

Cannot define statistic without also defining filter_all_stats_on

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:ineach'
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:insend'
from /Users/alhafoudh/Projects/bankomap.sk/vendor/plugins/statistics/lib/statistics.rb:133:in `get_stat'
from (irb):6

How can I group by ranges (such as weeks?)

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?

How can i use statistics to create a true time-series, showing 0 for null-values?

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?

primary_key is ignored

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.

creating a stats array

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

How can I create a time-series (say, count by dates) using statistics?

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.

Error

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

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.