Sha256: ec0ad7c09d35d674b34f41d5947f52ed7b07b866febff25a38ea99fb6f8d624c

Contents?: true

Size: 1.75 KB

Versions: 4

Compression:

Stored size: 1.75 KB

Contents

module ActivityFeed
  module Item
    # Add or update an item in the activity feed for a given +user_id+.
    #
    # @param user_id [String] User ID.
    # @param item_id [String] Item ID.
    # @param timestamp [int] Timestamp for the item being added or updated.
    # @param aggregate [boolean, false] Whether to add or update the item in the aggregate feed for +user_id+.
    def update_item(user_id, item_id, timestamp, aggregate = ActivityFeed.aggregate)
      feederboard = ActivityFeed.feederboard_for(user_id, false)
      feederboard.rank_member(item_id, timestamp)

      if aggregate
        feederboard = ActivityFeed.feederboard_for(user_id, true)
        feederboard.rank_member(item_id, timestamp)
      end
    end

    # Specifically aggregate an item in the activity feed for a given +user_id+. 
    # This is useful if you are going to background the process of populating 
    # a user's activity feed from friend's activities.
    #
    # @param user_id [String] User ID.
    # @param item_id [String] Item ID.
    # @param timestamp [int] Timestamp for the item being added or updated.
    def aggregate_item(user_id, item_id, timestamp)
      feederboard = ActivityFeed.feederboard_for(user_id, true)
      feederboard.rank_member(item_id, timestamp)
    end

    # Remove an item from the activity feed for a given +user_id+. This 
    # will also remove the item from the aggregate activity feed for the
    # user.
    # 
    # @param user_id [String] User ID.
    # @param item_id [String] Item ID.
    def remove_item(user_id, item_id)
      feederboard = ActivityFeed.feederboard_for(user_id, false)
      feederboard.remove_member(item_id)
      feederboard = ActivityFeed.feederboard_for(user_id, true)
      feederboard.remove_member(item_id)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
activity_feed-2.2.0 lib/activity_feed/item.rb
activity_feed-2.1.0 lib/activity_feed/item.rb
activity_feed-2.0.0 lib/activity_feed/item.rb
activity_feed-2.0.0.rc1 lib/activity_feed/item.rb