Module: Tekeya::Feed::Notification

Extended by:
ActiveSupport::Concern
Defined in:
lib/tekeya/feed/notification.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#read!Object

Marks the notification as read



53
54
55
# File 'lib/tekeya/feed/notification.rb', line 53

def read!
  self.update_attribute :read, true
end

#score(from_time = nil) ⇒ Integer

Approximates the timestamp to the nearest 15 minutes for grouping activities

Parameters:

  • from_time (Datetime) (defaults to: nil)

    the time to approximate

Returns:

  • (Integer)

    the timestamp approximated to the nearest 15 minutes



41
42
43
44
45
46
47
48
49
50
# File 'lib/tekeya/feed/notification.rb', line 41

def score(from_time = nil)
  if from_time.present?
    stamp = from_time.to_i

    # floors the timestamp to the nearest 15 minute
    return (stamp.to_f / 15.minutes).floor * 15.minutes
  else
    return current_time_from_proper_timezone.to_i
  end
end