Permalink
Browse files

Add :posts timeline

  • Loading branch information...
1 parent 962686c commit 17c1569a2c1e233f7540c09fea9d4a57368aa22d @felixclack committed Feb 27, 2012
Showing with 10 additions and 7 deletions.
  1. +1 −0 History.txt
  2. +2 −0 lib/timeline/actor.rb
  3. +7 −7 lib/timeline/track.rb
View
@@ -1,6 +1,7 @@
== 0.1.4 / 2012-02-28
* fix bug in extra fields
+* add activity to user's posts timeline
== 0.1.3 / 2012-02-28
View
@@ -21,6 +21,8 @@ def timeline_options(options)
case options
when :global
defaults.merge!(list_name: "global:activity")
+ when :posts
+ defaults.merge!(list_name: "user:id:#{self.id}:posts")
end
end
end
View
@@ -45,21 +45,21 @@ def activity(options={})
def add_activity(activity_item, followers)
redis_add "global:activity", activity_item
- add_activity_to_user(activity_item, activity_item[:actor][:id])
- add_activity_to_user_post(activity_item, activity_item[:actor][:id])
- add_activity_to_followers(activity_item, followers) if followers.any?
+ add_activity_to_user(activity_item[:actor][:id], activity_item)
+ add_activity_by_user(activity_item[:actor][:id], activity_item)
+ add_activity_to_followers(followers, activity_item) if followers.any?
end
- def add_activity_to_user(activity_item, user_id)
+ def add_activity_to_user(user_id, activity_item)
redis_add "user:id:#{user_id}:activity", activity_item
end
- def add_activity_to_user_post(activity_item, user_id)
+ def add_activity_by_user(user_id, activity_item)
redis_add "user:id:#{user_id}:posts", activity_item
end
- def add_activity_to_followers(activity_item, followers)
- followers.each { |follower| add_activity_to_user(activity_item, follower.id) }
+ def add_activity_to_followers(followers, activity_item)
+ followers.each { |follower| add_activity_to_user(follower.id, activity_item) }
end
def add_extra_fields(extra_fields)

0 comments on commit 17c1569

Please sign in to comment.