Module: Tekeya::Feed::Activity
- Extended by:
- ActiveSupport::Autoload, ActiveSupport::Concern
- Defined in:
- lib/tekeya.rb,
lib/tekeya/feed/activity.rb,
lib/tekeya/feed/activity/item.rb,
lib/tekeya/feed/activity/resque.rb,
lib/tekeya/feed/activity/resque/feed_copy.rb,
lib/tekeya/feed/activity/resque/untrack_feed.rb,
lib/tekeya/feed/activity/resque/activity_fanout.rb,
lib/tekeya/feed/activity/resque/delete_activity.rb
Defined Under Namespace
Instance Method Summary collapse
-
#activity_key ⇒ String
Returns an activity key for usage in caching.
-
#cached_in_redis? ⇒ Boolean
Check if this activity is cached in redis.
-
#score(from_time = nil) ⇒ Integer
Approximates the timestamp to the nearest 15 minutes for grouping activities.
Instance Method Details
#activity_key ⇒ String
Returns an activity key for usage in caching
63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/tekeya/feed/activity.rb', line 63 def activity_key k = [] k[0] = 'activity' k[1] = self.id k[2] = self.entity_type k[3] = self.entity.send(self.entity.entity_primary_key) k[4] = self. k[5] = self..send(self..entity_primary_key) k[6] = self.activity_type k[7] = score(self.created_at) k.join(':') end |
#cached_in_redis? ⇒ Boolean
Check if this activity is cached in redis
30 31 32 |
# File 'lib/tekeya/feed/activity.rb', line 30 def cached_in_redis? ::Tekeya.redis.scard(activity_key) > 0 end |
#score(from_time = nil) ⇒ Integer
Approximates the timestamp to the nearest 15 minutes for grouping activities
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/tekeya/feed/activity.rb', line 38 def score(from_time = nil) if self.group_with_recent 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 else 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 Time.now.to_i end end end |