Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jul 9, 2025. It is now read-only.
/reportablePublic archive
forked fromsaulabs/reportable

A plugin that makes basic reporting for rails models dead simple. Formally known as reports_as_sparkline.

License

NotificationsYou must be signed in to change notification settings

octanner/reportable

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

Reportable allows for the easy creation of reports based onActiveRecord models.

O.C.Tanner fork to support ruby 2.3.1

Usage

Usage is pretty easy. To declare a report on a model, simply define that the model provides a report:

class User < ActiveRecord::Base  reportable :registrations, :aggregation => :countend

Thereportable method takes a bunch more options which are described in theAPI docs. For example you could generate a report onthe number of updated users records per second or the number of registrations of users that have a last name that starts with'A' per month:

class User < ActiveRecord::Base  reportable :last_name_starting_with_a_registrations, :aggregation => :count, :grouping => :month, :conditions => ["last_name LIKE 'A%'"]  reportable :updated_per_second, :aggregation => :count, :grouping => :hour, :date_column => :updated_atend

For every declared report a method is generated on the model that returns the date:

User.registrations_reportUser.last_name_starting_with_a_registrations_reportUser.updated_per_second_report

Working with the data

The data is returned as anArray ofArrays ofDateTimes andFloats, e.g.:

[  [DateTime.now,          1.0],  [DateTime.now - 1.day,  2.0],  [DateTime.now - 2.days, 3.0]]

Reportable provides helper methods to generate a sparkline image from this data that you can use in your views, e.g.:

<%= google_report_tag(User.registrations_report) %>

For other options to generate sparklines see theAPI docs.

Installation

To install the Reportable gem, simply run

[sudo] gem install reportable

Rails 3.x

To install Reportable for Rails 3.x, add it to your application's Gemfile:

gem 'reportable', :require => 'saulabs/reportable'

and generate the migration that create reportable's cache table (beware that reportable currently only supports ActiveRecord):

rails generate reportable_migration

If you want to use reportable's JavaScript graph output format, you also have to generate the JavaScript files:

rails generate reportable_raphael_assets

if you want to useRaphael or if you want to usejQuery andflot:

rails generate reportable_jquery_flot_assets

Plans

  • add support for Oracle and MSSQL
  • add support for DataMapper
  • add more options to generate graphs from the data
  • add the option to generate textual reports on the command line

Authors

© 2008-2012 Marco Otte-Witte (http://simplabs.com) and Martin Kavalar (http://www.sauspiel.de)

Released under the MIT license

Contributors

About

A plugin that makes basic reporting for rails models dead simple. Formally known as reports_as_sparkline.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby100.0%

[8]ページ先頭

©2009-2025 Movatter.jp