Giter Site home page Giter Site logo

hkp / reportable Goto Github PK

View Code? Open in Web Editor NEW

This project forked from saulabs/reportable

0.0 2.0 0.0 1.18 MB

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

Home Page: http://saulabs.net/projects/reportable

License: MIT License

reportable's Introduction

Reportable

Build Status

Reportable allows for the easy creation of reports based on ActiveRecord models.

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 => :count

end

The reportable method takes a bunch more options which are described in the API docs. For example you could generate a report on the 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_at

end

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

User.registrations_report

User.last_name_starting_with_a_registrations_report

User.updated_per_second_report

Working with the data

The data is returned as an Array of Arrays of DateTimes and Floats, 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 the API 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 use Raphael or if you want to use jQuery and flot:

	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

reportable's People

Contributors

cristibalan avatar eric avatar kommen avatar larskuhnt avatar marcoow avatar mk avatar msch avatar myronmarston avatar pelf avatar schoefmann avatar shemerey avatar

Watchers

 avatar  avatar

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.