Class: SirTracksAlot::Activity

Inherits:
Persistable
  • Object
show all
Extended by:
FilterHelper
Includes:
EventHelper
Defined in:
lib/sir_tracks_alot/activity.rb

Constant Summary collapse

ACTIONS =
[:create, :view, :login, :search, :update, :destroy]

Constants included from EventHelper

EventHelper::DATE_FORMATS

Class Method Summary collapse

Instance Method Summary collapse

Methods included from FilterHelper

extract_filter_options, filter

Methods included from EventHelper

#views, #visits

Methods inherited from Persistable

#==, #eql?, find_or_create, #hash, #to_hash

Class Method Details

.create(attrs) ⇒ Object

Create with defaults: counted = 0



32
33
34
# File 'lib/sir_tracks_alot/activity.rb', line 32

def create(attrs)        
  ohm_create(attrs.merge(:counted => '0'))
end

.ohm_createObject



29
# File 'lib/sir_tracks_alot/activity.rb', line 29

alias_method :ohm_create, :create

.purge!(options_for_find = {}, options_for_sort = {:order => 'DESC', :start => 500, :limit => 500}) ⇒ Object

Delete 500 counted activities, leaving a default of the 500 most recent for the provided search criteria



43
44
45
# File 'lib/sir_tracks_alot/activity.rb', line 43

def self.purge!(options_for_find = {}, options_for_sort = {:order => 'DESC', :start => 500, :limit => 500})
  recent(options_for_find.merge(:counted => 1), options_for_sort).each{|a| a.delete}
end

.recent(options_for_find, options_for_sort = {:order => 'DESC', :limit => 500}) ⇒ Object

find recent activities



38
39
40
# File 'lib/sir_tracks_alot/activity.rb', line 38

def self.recent(options_for_find, options_for_sort = {:order => 'DESC', :limit => 500})
  find(options_for_find).sort_by(:last_event, options_for_sort)
end

Instance Method Details

#counted!Object

set this activity to counted and clear the recorded events



49
50
51
52
53
# File 'lib/sir_tracks_alot/activity.rb', line 49

def counted!
  update(:counted => '1')
  events.clear
  true
end

#counted?Boolean

is this activity counted?

Returns:

  • (Boolean)


56
57
58
# File 'lib/sir_tracks_alot/activity.rb', line 56

def counted?
  counted == '1'
end