Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cmeiklejohn/histomatic
Quick 'n dirty histograms for ActiveRecord.
https://github.com/cmeiklejohn/histomatic
Last synced: about 2 months ago
JSON representation
Quick 'n dirty histograms for ActiveRecord.
- Host: GitHub
- URL: https://github.com/cmeiklejohn/histomatic
- Owner: cmeiklejohn
- License: mit
- Created: 2012-02-16T22:28:26.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2012-02-20T02:20:59.000Z (almost 13 years ago)
- Last Synced: 2024-10-26T08:59:02.848Z (2 months ago)
- Language: Ruby
- Homepage: http://github.com/cmeiklejohn/histomatic
- Size: 96.7 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.markdown
- License: LICENSE
Awesome Lists containing this 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:
```ruby
Histomatic.generate(
Purchase,
'amount',
[0, 10, 20]
).to_hash # { 0 => 2, 10 => 0, 20 => 0 }
```Provide an ActiveRelation:
```ruby
Histomatic.generate(
Purchase.where(:name => 'Chris'),
'amount',
[0, 10, 20]
).to_hash # { 0 => 1, 10 => 0, 20 => 0 }
```Provide a transformation as the column:
```ruby
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.