Thursday, June 4, 2009

Newsfeeds Status Update

The Newsfeed concept is very simple - stream updates about things on the site, link to them, and offer ways they can be viewed outside the application.

The Newsfeed logic works by using a onCreate, onUpdate, and onDelete hook to create and save new feed items for a group of receivers, like programs and users that are associated with it. On the view side, these feed items are loaded, cached, and rendered.

There is then a simple HTML template that creates a table containing each update, with a link back to the sender entity, the type of update, and a timesince property. It can also render a payload for each feeditem, which can be any HTML or widget.

The receiver logic needs to be hardcoded for each entity type (or sometimes, groups of subclassed entities). I spent a few days trying to make a universal logic component, but the linkable scope property isn't designed for this kind of threading between entities. So the FeedItem model each stores a sender_key and a receiver_key. A one to many relationship via PolyMorphism would also be possible, but wouldn't necessarily be advantageous from a performance perspective.


The next tasks I'll be working on are tests (and tests for surveys), and then feed export functionality. I'd also like to do some refactoring to make it easier to subclass newsfeed functionality and to propagate "waves" of newsfeed updates as events bubbling up the heirarchy.

Speaking of which, it would be a lot of fun to make a Google Wave integration...

1 comment:

  1. James it would be really great if you would share with us about your work on Surveys module :-)

    ReplyDelete