我很想听听你对实现社交活动流的最佳方式(Facebook就是最著名的例子)的看法。涉及的问题/挑战有:

不同类型的活动(张贴,评论..) 不同类型的对象(帖子,评论,照片..) 1-n个不同角色的用户(“用户x回复了用户y对用户Z帖子的评论”) 同一活动项的不同视图(“您评论了..”vs。“你的朋友x评论”vs。"用户x评论说.."3个“评论”活动的表示)

. .还有更多,特别是如果你把它提高到一个高度复杂的水平,比如,把几个活动项目合并成一个(“用户x, y和z评论了那张照片”)。

任何关于模式、论文等关于最灵活、有效和强大的方法来实现这样一个系统、数据模型等的想法或建议都将受到欢迎。

尽管大多数问题与平台无关,但我最终有可能在Ruby on Rails上实现这样一个系统


当前回答

这是一个很好的演示,概述了Etsy.com是如何构建他们的活动流的。这是我在这个主题上找到的最好的例子,尽管它不是特定于rails的。

http://www.slideshare.net/danmckinley/etsy-activity-feeds-architecture

其他回答

我认为Plurk的方法很有趣:他们以一种看起来很像谷歌Finance的股票图表的格式提供你的整个时间轴。

想要了解一个社交网络是如何运作的,不妨看看Ning。开发人员页面看起来特别有用。

我在几个月前解决了这个问题,但我认为我的实现太基础了。 我创建了以下模型:

HISTORY_TYPE

ID           - The id of the history type
NAME         - The name (type of the history)
DESCRIPTION  - A description

HISTORY_MESSAGES

ID
HISTORY_TYPE - A message of history belongs to a history type
MESSAGE      - The message to print, I put variables to be replaced by the actual values

HISTORY_ACTIVITY

ID
MESSAGE_ID    - The message ID to use
VALUES        - The data to use

例子

MESSAGE_ID_1 => "User %{user} created a new entry"
ACTIVITY_ID_1 => MESSAGE_ID = 1, VALUES = {user: "Rodrigo"}

After implementing activity streams to enable social feeds, microblogging, and collaboration features in several applications, I realized that the base functionality is quite common and could be turned into an external service that you utilize via an API. If you are building the stream into a production application and do not have unique or deeply complex needs, utilizing a proven service may be the best way to go. I would definitely recommend this for production applications over rolling your own simple solution on top of a relational database.

我的公司collaboration (http://www.collabinate.com)就是从这种实现中发展出来的,我们在图形数据库上实现了一个可伸缩的高性能活动流引擎来实现它。实际上,我们使用了Graphity算法的变体(改编自@RenePickhardt的早期工作,他也在这里提供了答案)来构建引擎。

如果您希望自己托管引擎或需要特殊功能,其核心代码实际上是非商业用途的开源代码,因此欢迎您查看。

// one entry per actual event
events {
  id, timestamp, type, data
}

// one entry per event, per feed containing that event
events_feeds {
  event_id, feed_id
}

创建事件时,决定它出现在哪个提要中,并将这些提要添加到events_feeds中。 要获取提要,请从events_feeds中选择,加入事件,按时间戳排序。 然后可以对该查询的结果进行过滤和聚合。 使用此模型,您可以在创建后更改事件属性,而不需要额外的工作。

如果你决定用Rails实现,也许你会发现下面的插件很有用:

ActivityStreams: http://github.com/face/activity_streams/tree/master

如果没有其他问题,您将从数据模型和为推拉活动提供的API两方面来研究一个实现。