Project

histomatic

0.0
No commit activity in last 3 years
No release in over 3 years
Quick 'n dirty histograms.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

>= 0
 Project Readme

Histomatic

Quick n' dirty histograms for Rails.

Notice

Currently in development, and only supports the mysql2 driver.

Usage

Generate a histogram providing an input source, which is either an ActiveRecord class or instance of ActiveRelation, a column as a string, and groupings.

Currently the column must return a numeric.

Examples

Provide a class:

Histomatic.generate(
  Purchase, 
  'amount', 
  [0, 10, 20]
).to_hash # { 0 => 2, 10 => 0, 20 => 0 }

Provide an ActiveRelation:

Histomatic.generate(
  Purchase.where(:name => 'Chris'), 
  'amount', 
  [0, 10, 20]
).to_hash # { 0 => 1, 10 => 0, 20 => 0 }

Provide a transformation as the column:

Histomatic.generate(
  Purchase.where(:name => 'Chris'), 
  'datediff(current_date, purchases.created_at)', 
  [0, 10, 20]
).to_hash # { 0 => 0, 10 => 1, 20 => 0 }

License

Histomatic is Copyright © 2012 Christopher Meiklejohn. Histomatic is free software, and may be redistributed under the terms specified in the LICENSE file.