<commit_before># Statistics

This ActiverRecord plugin allows you to easily define and pull statistics for AR models. This plugin was built with reporting in mind.

## Installation
    script/plugin install git://github.com/acatighera/statistics.git

## Examples
#### Defining statistics is similar to defining named scopes. Strings and symbols both work as names.

    class Account < ActiveRecord::Base
      define_statistic :user_count, :count => :all
      define_statistic :average_age, :average => :all, :column_name => 'age'
      define_statistic 'subscriber count', :count => :all, :conditions => "subscription_opt_in = 1"
    end
    
    class Donations < ActiveRecord::Base
      define_statistic :total_donations, :sum => :all, :column_name => "amount"
    end

#### Actually pulling the numbers is simple:

#####for all stats

    Account.statistics                   # returns { :user_count => 120, :average_age => 28, 'subscriber count' => 74 }

#####for a single stat

    Account.get_stat(‘:user_count’)      # returns 120

### Here are some additional benefits of using this plugin:<commit_msg>and another tweak to README<commit_after># Statistics

This ActiverRecord plugin allows you to easily define and pull statistics for AR models. This plugin was built with reporting in mind.

## Installation
    script/plugin install git://github.com/acatighera/statistics.git

## Examples
#### Defining statistics is similar to defining named scopes. Strings and symbols both work as names.

    class Account < ActiveRecord::Base
      define_statistic :user_count, :count => :all
      define_statistic :average_age, :average => :all, :column_name => 'age'
      define_statistic 'subscriber count', :count => :all, :conditions => "subscription_opt_in = 1"
    end
    
    class Donations < ActiveRecord::Base
      define_statistic :total_donations, :sum => :all, :column_name => "amount"
    end

#### Actually pulling the numbers is simple:

#####for all stats

    Account.statistics                   # returns { :user_count => 120, :average_age => 28, 'subscriber count' => 74 }

#####for a single stat

    Account.get_stat(:user_count)      # returns 120

### Here are some additional benefits of using this plugin:
{'fraction_non_alphanumeric': 0.10267857142857142, 'fraction_numerical': 0.009821428571428571, 'mean_word_length': 3.7378435517970403, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3046849', 'n_tokens_mistral': 646, 'n_tokens_neox': 606, 'n_words': 223}