Class: LittleBrother::Utils
- Inherits:
-
Object
- Object
- LittleBrother::Utils
- Defined in:
- lib/little_brother/utils.rb
Class Method Summary collapse
-
.keep_only_last_months(number_of_months) ⇒ Object
TODO: Validate number_of_months.
- .truncate_watchers ⇒ Object
- .user_actions_in_timeframe(user, start_date, end_date) ⇒ Object
Class Method Details
.keep_only_last_months(number_of_months) ⇒ Object
TODO: Validate number_of_months
8 9 10 |
# File 'lib/little_brother/utils.rb', line 8 def self.keep_only_last_months(number_of_months) Watcher.find(:all, :conditions => ['created_at < ?', Time.now-number_of_months.months]) end |
.truncate_watchers ⇒ Object
3 4 5 |
# File 'lib/little_brother/utils.rb', line 3 def self.truncate_watchers ActiveRecord::Base.connection.execute("truncate table watchers") end |
.user_actions_in_timeframe(user, start_date, end_date) ⇒ Object
12 13 14 15 16 |
# File 'lib/little_brother/utils.rb', line 12 def self.user_actions_in_timeframe(user, start_date, end_date) unless user.nil? || start_date.nil? || end_date.nil? Watcher.where(:user => user, :created_at => start_date..end_date) end end |