lib/tekeya/entity.rb in tekeya-0.0.7 vs lib/tekeya/entity.rb in tekeya-0.0.9
- old
+ new
@@ -34,11 +34,11 @@
args.each do |attachable|
attachments << ::Tekeya::Attachment.new(attachable: attachable)
end
- create(activity_type: meth, attachments: attachments, group_with_recent: options[:group].nil? ? true : options[:group])
+ create(activity_type: meth, attachments: attachments, group_with_recent: options[:group].nil? ? true : options[:group], author: options[:author])
else
super
end
end
end
@@ -310,16 +310,22 @@
if recent_activities_count > 0
# Retrieve the aggregate keys from redis
acts_keys = ::Tekeya.redis.zrevrange(pkey, 0, -1)
# Retrieve the aggregates
acts_keys.each do |act_key|
- acts << ::Tekeya::Feed::Activity::Item.from_redis(act_key, self)
+ # Make `from_redis` only hit the db if author != entity
+ key_components = act_key.split(':')
+ actor = if key_components[4] == self.class.to_s && key_components[5] == self.entity_primary_key
+ self
+ end
+
+ acts << ::Tekeya::Feed::Activity::Item.from_redis(act_key, actor)
end
else
# Retrieve the activities from the DB
db_recent_activities = self.activities.recent
db_recent_activities.each do |activity|
- acts << ::Tekeya::Feed::Activity::Item.from_db(activity, self)
+ acts << ::Tekeya::Feed::Activity::Item.from_db(activity, activity.author)
end
end
return acts
end