Repository is archived
No commit activity in last 3 years
No release in over 3 years
A methods for calculates agregate values by time range.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

 Project Readme

Calculations By Time Range¶ ↑

Add new methods for ActiveRecord to get agregate values by time range.

Install & use¶ ↑

Install the gem from rubyforge:

sudo gem install calculations_by_time_range

Now just set it as a dependency in your project and you are ready to go.

You can also install this as a plugin:

script/plugin install git://github.com/miry/calculations_by_time_range.git

See below for usage examples.

Usage¶ ↑

# We have the following model
User(id: integer, created_at: datetime, updated_at: datetime, username: string, age: integer)

# CalculationsByTimeRange gives you a bunch of named scopes for free:
User.counts_by_day
User.counts_by(:day)
User.counts_by(:day, '*', 'updated_at')
User.sums_by(:week, 'age')

Examples with Searchlogic and scopes¶ ↑

User.created_at_gt(1.day.ago).counts_by_hours

Note on Patches/Pull Requests¶ ↑

  • Fork the project.

  • Make your feature addition or bug fix.

  • Add tests for it. This is important so I don’t break it in a future version unintentionally.

  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)

  • Send me a pull request. Bonus points for topic branches.

Copyright © 2010 Michael Nikitochkin of JetThoughts, released under the MIT license