Description
The Chartable gem is a lightweight and database-level library to transform any Active Record query into analytics hash ready for use with any chart library.
The Chartable Ruby gem alternatives and similar gems
Based on the "Analytics" category.
Alternatively, view The Chartable Ruby gem alternatives based on common mentions on social networks and blogs.
-
Rack::Tracker
Tracking made easy: Don’t fool around with adding tracking and analytics partials to your app and concentrate on the things that matter. -
Staccato
Ruby library to perform server-side tracking into the official Google Analytics Measurement Protocol -
RailsUrlShortener
RailsUrlShortener is a lightweight Rails engine that enables easy creation and management of short URLs within your project. Similar to bitly.com, it condenses long links into short, user-friendly addresses. Enhance your app's functionality with this simple yet powerful URL shortening solution. -
RequestResponseStats
A Ruby gem which captures request response statistics such as cycle time, memory allocation, etc. for each request response cycle grouped in configurable granularity level. As this library makes use of TCP protocol, using DataDog or NewRelic RPM would be way faster because of UDP protocol.
Scout Monitoring - Performance metrics and, now, Logs Management Monitoring with Scout Monitoring
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of The Chartable Ruby gem or a related project?
README
The Chartable Ruby gem
The Chartable gem is a lightweight and database-level library to transform any Active Record query into analytics hash ready for use with any chart library.
Supported database engines: MySQL
and PostgreSQL
Installation
gem install chartable
Usage examples
The gem adds the analytics
class method to all Rails models. Currently, five analytics periods are available: yearly
, weekly
, monthly
, quarterly
and daily
. If it's not specified then it operates on the created_at
column.
User.analytics(:yearly) # => { 2017 => 5, 2018 => 30 }
User.analytics(:monthly) # => { "November 2018" => 1, "October 2018" => 1 }
User.analytics(:daily) # => {"October 09, 2018" => 1, "October 10, 2018" => 1}
User.analytics(:weekly) # => {"01/28/18 - 02/03/18" => 1, "02/11/18 - 02/17/18" => 1}
User.analytics(:quarterly) # => {"Q1 2018" => 1, "Q2 2018" => 1}
If you want to change the column used for sorting then specify the :on
option:
User.analytics(:yearly, on: 'updated_at')
If you want to narrow the results you can pass from:
or/and to:
options. You can pass any valid value of type String
, Date
, DateTime
or Time
- it will be transformed to the date format:
User.analytics(:yearly, from: Date.yesterday, to: Date.today)
You can also call analytics
on any query:
User.where(first_name: 'John').where.not(last_name: 'Doe').analytics(:daily)
Sorting
With the 0.0.0.3
version is possible to sort results:
User.analytics(:yearly, order: 'desc') # or order: 'asc'
Supported Ruby Versions
This gem was tested on the 2.5.0 version. If it's not working with older versions please add a new issue.
Committers and Contributors
TODO
- Add the CHANGELOG file
- Add a separated query class for each database driver
- When a date period is restricted then return 0 for periods without the data
- Test code with the older Ruby versions
Copyright
Copyright (c) 2018 Paweł Dąbrowski. See [LICENSE][] for details.
*Note that all licence references and agreements mentioned in the The Chartable Ruby gem README section above
are relevant to that project's source code only.